Recall & Review
beginner Click to reveal answer
What does 'Insert at Beginning' mean in a linked list?
It means adding a new node at the start (head) of the linked list, making it the first element.
beginner Click to reveal answer
Why is inserting at the beginning of a linked list efficient?
Because it only changes the head pointer and the new node's next pointer, so it takes constant time O(1).
beginner Click to reveal answer
In TypeScript, what properties does a linked list node usually have?
A node usually has a 'value' to store data and a 'next' pointer to the next node or null if it's the last.
beginner Click to reveal answer
What happens to the old head node when a new node is inserted at the beginning?
The old head becomes the second node; the new node points to it as its next node.
beginner Click to reveal answer
Show the steps to insert a new node with value 5 at the beginning of a linked list.
1. Create new node with value 5.
2. Set new node's next to current head.
3. Update head to new node.
2. Set new node's next to current head.
3. Update head to new node.
What is the time complexity of inserting a node at the beginning of a linked list?
✗ Incorrect
Inserting at the beginning only changes pointers and does not depend on list size, so it is O(1).
When inserting at the beginning, what does the new node's next pointer point to?
✗ Incorrect
The new node points to the current head to keep the list connected.
If the linked list is empty, what should the new node's next pointer be after insertion at beginning?
✗ Incorrect
If the list is empty, the new node points to null because there is no next node.
Which pointer is updated to insert a node at the beginning?
✗ Incorrect
The head pointer is updated to point to the new node.
What is the first step when inserting a node at the beginning?
✗ Incorrect
You must first create the new node before linking it.
Explain how to insert a new node at the beginning of a singly linked list.
Think about what happens to the head pointer and the new node's next pointer.
You got /3 concepts.
Why is inserting at the beginning of a linked list faster than inserting at the end?
Consider how many nodes you need to visit for each insertion.
You got /3 concepts.
