Recall & Review
beginner
What is a circular linked list?
A circular linked list is a linked list where the last node points back to the first node, forming a circle. There is no NULL at the end.
Click to reveal answer
intermediate
Why do we need to update the last node when inserting at the beginning of a circular linked list?
Because the last node points to the first node, when we insert a new node at the beginning, the last node's next pointer must be updated to point to the new first node.
Click to reveal answer
beginner
What happens if the circular linked list is empty and we insert a node at the beginning?
The new node points to itself, making it both the first and last node, forming a single-node circular linked list.
Click to reveal answer
intermediate
Show the steps to insert a new node at the beginning of a non-empty circular linked list.
1. Create new node with data.<br>2. Find the last node (node whose next points to head).<br>3. Set new node's next to head.<br>4. Set last node's next to new node.<br>5. Update head to new node.
Click to reveal answer
intermediate
What is the time complexity of inserting at the beginning of a circular linked list if we do not keep a tail pointer?
O(n), because we need to traverse the list to find the last node before updating its next pointer.
Click to reveal answer
In a circular linked list, what does the last node's next pointer point to?
✗ Incorrect
In a circular linked list, the last node points back to the first node to form a circle.
When inserting at the beginning of a circular linked list, which pointer must be updated besides the new node's next?
✗ Incorrect
The last node's next pointer must point to the new first node to maintain the circular structure.
If the circular linked list is empty, what should the new node's next pointer point to after insertion at beginning?
✗ Incorrect
For a single node circular linked list, the node points to itself.
What is the time complexity of inserting at the beginning of a circular linked list without a tail pointer?
✗ Incorrect
Finding the last node requires traversing the list, which takes O(n) time.
Which of the following is true about circular linked lists?
✗ Incorrect
Because the list is circular, you can start traversal from any node and visit all nodes.
Explain how to insert a new node at the beginning of a circular linked list and why updating the last node is necessary.
Think about the circular link from last node to first node.
You got /5 concepts.
Describe the difference in insertion steps when the circular linked list is empty versus when it has nodes.
Consider the special case of a single node.
You got /4 concepts.
