Data Structure Questions and Answers-Doubly Linked List

Data Structure Questions and Answers-Doubly Linked List

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%%


Your answers are highlighted below.
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)
Aptitude test Questions answers
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(node
public 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.
Civics Test Questions answers
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]
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
Find your subjects study note
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
Aptitude Questions answers
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]
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()); 	head.setNext(temp); 	temp.getNext().setPrev(temp); 	Node temp1 = tail.getPrev(); 	tail.setPrev(temp1.getPrev()); 	temp1.getPrev().setNext(tail);
A
head-6-1-2-3-4-5-tail
B
head-6-1-2-3-4-tail
C
head-1-2-3-4-5-6-tail
D
head-1-2-3-4-5-tail
English grammar Questions answers
Question 10 Explanation: 
A new node is added to the head of the list and a node is deleted from the tail end of the list.

Digital Education is a concept to renew the education system in the world. It is a program that endeavors to bridge the literacy slippage by delivering education through a digital platform to children and teachers. You can tell your friends regarding our intiative, click share button below. Share it
There are 10 questions to complete.