What does the 'push' operation do in a linked list?
It adds a new node at the beginning (head) of the linked list, making it the new first element.
Click to reveal answer
beginner
In the push operation, why do we set the new node's next pointer to the current head?
Because the new node should point to the old first node, preserving the rest of the list after insertion.
Click to reveal answer
beginner
What is the time complexity of the push operation in a singly linked list?
O(1) — It takes constant time because it only changes a few pointers at the head.
Click to reveal answer
beginner
Show the C# code snippet to push a new node with value 10 to the head of a linked list.
Node newNode = new Node(10);
newNode.Next = head;
head = newNode;
Click to reveal answer
beginner
What happens to the head pointer after a push operation?
The head pointer is updated to point to the new node, which is now the first node in the list.
Click to reveal answer
What does the push operation add to a linked list?
ADeletes the first node
BA new node at the end
CA new node in the middle
DA new node at the beginning
✗ Incorrect
Push adds a new node at the beginning (head) of the linked list.
After pushing a new node, what does the new node's next pointer reference?
ANull
BItself
CThe old head node
DThe last node
✗ Incorrect
The new node's next pointer points to the old head node to keep the list connected.
What is the time complexity of the push operation in a singly linked list?
AO(n)
BO(1)
CO(log n)
DO(n^2)
✗ Incorrect
Push runs in constant time O(1) because it only changes the head pointer and one next pointer.
Which pointer is updated to the new node after a push?
AHead pointer
BTail pointer
CNext pointer of last node
DPrevious pointer
✗ Incorrect
The head pointer is updated to the new node after push.
If the linked list is empty, what will the new node's next pointer be after push?
ANull
BHead
CItself
DUndefined
✗ Incorrect
If the list is empty, the new node's next pointer is null because there are no other nodes.
Explain step-by-step how the push operation adds a new node to the start of a linked list.
Think about how the new node connects to the old list and how the head changes.
You got /3 concepts.
Describe why push operation in a linked list is efficient compared to adding at the end.
Consider how many nodes you need to visit to add at the start vs the end.
You got /3 concepts.
Practice
(1/5)
1. What does the push operation do in a linked list when using nodes?
easy
A. Adds a new node at the beginning of the list
B. Removes the last node from the list
C. Searches for a node with a specific value
D. Deletes the first node from the list
Solution
Step 1: Understand push operation in linked list
The push operation inserts a new node at the start of the linked list.
Step 2: Effect of push on list structure
The new node becomes the head, and its next pointer points to the old head.
Final Answer:
Adds a new node at the beginning of the list -> Option A
Quick Check:
Push means insert at head [OK]
Hint: Push always adds node at the start of the list [OK]
Common Mistakes:
Confusing push with pop operation
Thinking push adds at the end
Assuming push deletes nodes
2. Which of the following is the correct syntax to create a new node and push it onto a linked list in C#?
easy
A. Node newNode = new Node(); head = newNode.next; newNode.data = data;
B. Node newNode = new Node(data); newNode.next = head; head = newNode;
C. head = new Node(data); head.next = null;
D. Node newNode = new Node(data); head = newNode.next; newNode = head;
Solution
Step 1: Create new node with data
Use new Node(data) to create a node with the given data.
Step 2: Link new node to current head and update head
Set newNode.next = head and then head = newNode to push at front.
Final Answer:
Node newNode = new Node(data); newNode.next = head; head = newNode; -> Option B
Quick Check:
New node points to old head, then head updated [OK]
Hint: New node next points to head, then head updated [OK]
Common Mistakes:
Assigning head before setting newNode.next
Not initializing new node with data
Swapping head and newNode incorrectly
3. What will be the output linked list after executing this code?
Node head = null;
head = new Node(10);
head.next = new Node(20);
Node newNode = new Node(5);
newNode.next = head;
head = newNode;
Print the list from head to end.
medium
A. 10 -> 20 -> 5 -> null
B. 5 -> 20 -> 10 -> null
C. 20 -> 10 -> 5 -> null
D. 5 -> 10 -> 20 -> null
Solution
Step 1: Initial list creation
Head points to node 10, which points to node 20, then null.
Step 2: Push new node with value 5
New node 5 points to old head (10), then head updated to new node 5.
Final Answer:
5 -> 10 -> 20 -> null -> Option D
Quick Check:
New node added at front [OK]
Hint: New node points to old head, becomes new head [OK]
Common Mistakes:
Appending new node at end instead of front
Not updating head to new node
Confusing node order after push
4. Identify the error in this push method for a singly linked list:
public void Push(int data) {
Node newNode = new Node(data);
newNode.next = null;
head = newNode;
}
medium
A. newNode.next should point to current head before updating head
B. Node constructor is missing data parameter
C. head should be set to null before assigning newNode
D. No error, code is correct
Solution
Step 1: Analyze newNode.next assignment
Setting newNode.next = null disconnects new node from existing list.
Step 2: Correct linking for push operation
New node's next should point to current head to keep list intact before updating head.
Final Answer:
newNode.next should point to current head before updating head -> Option A
Quick Check:
Link new node to old head before head update [OK]
Hint: Link new node to old head before changing head [OK]
Common Mistakes:
Setting newNode.next to null breaks list
Not updating head after push
Confusing order of assignments
5. Given a linked list with nodes 30 -> 20 -> 10 -> null, you want to push nodes 40 and 50 in that order using the push method. What will be the final list?
hard
A. 30 -> 20 -> 10 -> 50 -> 40 -> null
B. 40 -> 50 -> 30 -> 20 -> 10 -> null
C. 50 -> 40 -> 30 -> 20 -> 10 -> null
D. 30 -> 20 -> 10 -> 40 -> 50 -> null
Solution
Step 1: Initial list and first push
Start with 30 -> 20 -> 10 -> null. Push 40: new head is 40, list is 40 -> 30 -> 20 -> 10 -> null.
Step 2: Second push with 50
Push 50: new head is 50, list becomes 50 -> 40 -> 30 -> 20 -> 10 -> null.
Final Answer:
50 -> 40 -> 30 -> 20 -> 10 -> null -> Option C
Quick Check:
Push adds nodes at front in reverse order [OK]
Hint: Last pushed node becomes new head [OK]
Common Mistakes:
Assuming push adds at end
Mixing order of pushed nodes
Not updating head after each push
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.