Doubly Linked Lists Questions and Answers
Doubly Linked Lists Questions and Answers
Ad removed. Details
2. Given the Node class implementation, select one of the following that correctly inserts a node at
the tail of the list.
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 1/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
a)
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 2/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
b)
c)
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 3/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
d)
advertisement
View Answer
4. Which of the following piece of code removes the node from a given position?
a)
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 4/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
b)
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 5/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
c)
d)
return;
if(pos == 0)
{
head = head.getNext();
if(head == null)
tail = null;
}
else
{
Node temp = head;
for(int i=1; i<position; i++)
temp = temp.getNext().getNext();
}
temp.getNext().setPrev(temp.getNext());
temp.getPrev().setNext(temp.getPrev());
}
size--;
}
View Answer
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
View Answer
6. What is the worst case time complexity of inserting a node in a doubly linked list?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(1)
View Answer
b)
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 7/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
c)
d)
View Answer
8. 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?
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
View Answer
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
View Answer
10. 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?
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
View Answer
To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions and
Answers.
« Prev - Data Structure Multiple Choice » Next - Data Structure Questions and Answers –
Questions – Linked List Circular Linked List
Related Posts:
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 9/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
advertisement
Recommended Articles:
1. C++ Program to Implement Sorted Doubly Linked List
2. C++ Program to Implement Sorted Circularly Doubly Linked List
3. C++ Program to Implement Triply Linked List
4. Data Structure Questions and Answers – Singly Linked List Operations – 3
5. Data Structure Multiple Choice Questions – Linked List
6. Data Structure Questions and Answers – Circular Linked List
7. C Program to Implement Doubly Linked List using Singly Linked List
8. Data Structure Questions and Answers – Singly Linked List Operations – 1
9. Java Program to Implement Doubly Linked List
10. C Program to Find the Largest Element in a Doubly Linked List
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 10/12
28/11/2023, 09:25 Doubly Linked Lists Questions and Answers - Sanfoundry
Additional Resources:
Linked List Programs in C
Linked List Programs in Python
Data Structures in C
Data Structure MCQ Questions
Data Structures in Java
Popular Pages:
Data Structures in C++
Python Programming Examples
C Tutorial
C Programs on Recursion
Data Science MCQ Questions
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at
Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies,
Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.
https://www.sanfoundry.com/data-structure-questions-answers-doubly-linked-lists/ 12/12