What is the main advantage of a doubly linked list over a singly linked list?
a) Allows for traversal in both directions
b) Uses less memory
c) Easier to implement
d) Supports faster sorting
Answer:
a) Allows for traversal in both directions
Explanation:
The main advantage of a doubly linked list over a singly linked list is that it allows for traversal in both directions. Each node in a doubly linked list contains two pointers: one to the next node and one to the previous node, enabling movement forward and backward through the list.
While doubly linked lists require more memory than singly linked lists due to the additional pointer, they are more flexible for operations like deletion and insertion, especially when the list is traversed in both directions.
Doubly linked lists are used in scenarios where bidirectional traversal is important, such as in certain types of caches or navigation systems.
Reference:
DSA (Data Structures and Algorithms) MCQ Questions and Answers