Question 41
What is the worst-case time complexity of searching for a value in an unsorted singly linked list?
A singly linked list has no direct indexing. In the worst case, the target is in the final node or absent, so every node must be examined.
What is the worst-case time complexity of searching for a value in an unsorted singly linked list?
A singly linked list has no direct indexing. In the worst case, the target is in the final node or absent, so every node must be examined.
What is the time complexity of deleting the first node of a non-empty singly linked list when the head pointer is available?
Deletion changes the head pointer to head.next and then releases the old node. No traversal is required.
Which pointer update is required to insert a new node at the beginning of a singly linked list?
The new node must point to the current first node before head is updated to the new node. This preserves access to the existing list.
In a circular singly linked list containing one node, what should its next pointer reference?
With one node, the node is both the first and last node. Circularity is maintained by pointing its next field back to itself.
Which data structure is most appropriate for implementing an undo operation in an editor?
Undo typically reverses the most recent operation first. A stack naturally supports this last-in, first-out behavior.