Challenge your understanding of singly, doubly, and circular linked lists as well as advanced techniques like Floyd’s Cycle Detection and merging operations. This quiz is designed to test your knowledge of key data structures and complex algorithmic strategies.
Singly Linked List: Node Deletion
In a singly linked list, what is the minimum information required to delete a node ‘X’ that is not the last node, given only a pointer to ‘X’?
- Store the head pointer and traverse from the start
- Access previous node and set its next to NULL
- Swap X with head and delete head
- Copy data from the next node into X and delete the next node
- Set X to NULL without modifying other nodes
Doubly Linked List: Reverse Traversal
When performing reverse traversal of a doubly linked list, what must be accessed from each node to move to the previous element?
- random pointer
- main pointer
- head pointer
- prev pointer
- next pointer
Circular Linked List: Infinite Loops
Which condition will guarantee an infinite loop in a singly circular linked list traversal?
- while(current != head)
- while(current != tail)
- while(current.next != head)
- while(current.next != current)
- while(current != NULL)
Floyd’s Cycle Detection: Tortoise and Hare
How does Floyd’s Cycle Detection algorithm ensure that a cycle exists in a linked list when both pointers meet at a node?
- Both pointers reach NULL at the same time
- Both slow and fast pointers revisit a node simultaneously
- Fast pointer jumps to head after every step
- Only slow pointer ever repeats a node
- Both pointers skip the cycle and exit
Merging Two Sorted Linked Lists
Given two sorted singly linked lists, what is the most efficient approach to merge them into a single sorted list using O(1) auxiliary space?
- Reverse both lists before merging
- Copy both lists to arrays and merge arrays
- Insert all nodes into a hash set
- Iteratively compare heads and link the smaller
- Recursively copy each node to a new list
Time Complexity: Doubly Linked List Deletion
What is the time complexity for deleting a given node in a doubly linked list, provided a direct reference to that node, but no head or tail pointers?
- O(log n)
- O(n log n)
- O(n)
- O(1)
- O(2n)
Circular Linked List: Insertion After Tail
When inserting a node after the tail in a circular singly linked list containing ‘n’ nodes, which pointers must be updated for proper linkage?
- No pointers, structure updates automatically
- New node’s prev only
- Only the new node’s next
- Tail’s next and the new node’s next
- Head’s next and tail’s next
Detecting Loop Starting Point
After identifying a cycle using Floyd’s algorithm, how can the start node of the cycle in a linked list be found?
- Rearrange nodes in reverse
- Move one pointer to head and advance both one step until meeting
- Remove random nodes until the loop breaks
- Check for NULL pointers
- Count nodes in the cycle and jump that many from head
Edge Case: Merging with Empty Lists
If you merge a non-empty sorted linked list L1 with an empty sorted linked list L2, what should be the resulting merged list?
- L1 remains unchanged
- Both lists are deleted
- L2 becomes a copy of L1
- Merged list cycles back to head
- L1 and L2 are concatenated twice
Tail Pointer Utility in Linked Lists
Which of the following operations is optimized by maintaining a direct tail pointer in a singly linked list?
- Faster deletion of middle nodes
- Efficient reverse traversal
- Quick access to minimum element
- Constant-time insertion at the end
- Loop detection using tail reference