Doubly Linked List | Data Structure MCQs

1.

Consider the following doubly linked list: head-1-2-3-4-5-tail
What will be the list after performing the given sequence of operations?

	Node temp = new Node(6,head,head.getNext());
	Node temp1 = new Node(0,tail.getPrev(),tail);
	head.setNext(temp);
	temp.getNext().setPrev(temp);
	tail.setPrev(temp1);
	temp1.getPrev().setNext(temp1);

   A.) head-0-1-2-3-4-5-6-tail
   B.) head-1-2-3-4-5-6-tail
   C.) head-6-1-2-3-4-5-0-tail
   D.) head-0-1-2-3-4-5-tail

Answer: Option 'C'

The given sequence of operations perform addition of nodes at the head and tail of the list.

2.

Which of the following is false about a doubly linked list?

   A.) We can navigate in both the directions
   B.) It requires more space than a singly linked list
   C.) The insertion and deletion of a node take a bit longer
   D.) None of these

Answer: Option 'D'

A doubly linked list has two pointers ‘left’ and ‘right’ which enable it to traverse in either direction. Compared to singly liked list which has only a ‘next’ pointer, doubly linked list requires extra space to store this extra pointer. Every insertion and deletion requires manipulation of two pointers, hence it takes a bit longer time.

3.

What is a memory efficient double linked list?

   A.) Each node has only one pointer to traverse the list back and forth
   B.) The list has breakpoints for faster traversal
   C.) An auxiliary singly linked list acts as a helper list to traverse through the doubly linked list
   D.) None of these

Answer: Option 'A'

Memory efficient doubly linked list has been proposed recently which has only one pointer to traverse the list back and forth. The implementation is based on pointer difference.

4.

What is the functionality of the following piece of code?

public int function()
{
	Node temp = tail.getPrev();
	tail.setPrev(temp.getPrev());
	temp.getPrev().setNext(tail);
	size--;
	return temp.getItem();
}

   A.) Return the element at the tail of the list but do not remove it
   B.) Return the element at the tail of the list and remove it from the list
   C.) Return the last but one element from the list but do not remove it
   D.) Return the last but one element at the tail of the list and remove it from the list

Answer: Option 'B'

​Return the element at the tail of the list and remove it from the list
The previous and next pointers of the tail and the last but one element are manipulated, this suggests that the last node is being removed from the list.

5.

How do you calculate the pointer difference in a memory efficient double linked list?

   A.) head xor tail
   B.) pointer to previous node xor pointer to next node
   C.) pointer to previous node – pointer to next node
   D.) pointer to next node – pointer to previous node

Answer: Option 'B'

pointer to previous node xor pointer to next node

Doubly Linked List | Data Structure MCQs Download Pdf

<