Congratulations - you have completed Data Structure Questions and Answers-Doubly Linked List.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%

 Question 6 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER]
What is the time complexity of inserting a node in a doubly linked list?
 A O(nlogn) B O(logn) C O(n) D O(1)
Question 6 Explanation:
In the worst case, the position to be inserted maybe at the end of the list, hence you have to traverse through the entire list to get to the correct position, hence O(n).

 Question 7 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER]
How do you insert a node at the beginning of the list?
 A public class insertFront(int data) { Node node = new Node(data, head, head.getNext()); node.getNext().setPrev(node); head.setNext(nodepublic class insertFront(int data) { Node node = new Node(data, head, head); node.getNext().setPrev(node); head.setNext(node); size++; public class insertFront(int data) { Node node = new Node(data, head, head.getNext()); node.getNext().setPrev(head); head.setNext(node D public class insertFront(int data) { Node node = new Node(data, head, head.getNext()); node.getNext().setPrev(node); head.setNext(node.
Question 7 Explanation:
The new node's previous pointer will point to head and next pointer will point to the current next of head.

 Question 8 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER]

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);
Question 8 Explanation:
The given sequence of operations perform addition of nodes at the head and tail of the list.

 Question 9 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER]
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
Question 9 Explanation:
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.

 Question 10 [CLICK ON ANY COICE TO KNOW RIGHT ANSWER]
	Node temp = new Node(6, head, head.getNext()); 	head.setNext(temp); 	temp.getNext().setPrev(temp); 	Node temp1 = tail.getPrev(); 	tail.setPrev(temp1.getPrev()); 	temp1.getPrev().setNext(tail);