A singly linked list is a collection of nodes where each node contains data and a reference (or link) to the next node in the sequence. It allows sequential access from the first node to the last.
Click to reveal answer
beginner
What are the main parts of a node in a singly linked list?
Each node has two parts: data, which stores the value, and next, which is a reference to the next node in the list or null if it is the last node.
Click to reveal answer
beginner
How do you traverse a singly linked list?
Start at the first node (called the head), then follow each node's next reference until you reach a node whose next is null, which means the end of the list.
Click to reveal answer
intermediate
What is the difference between a singly linked list and a doubly linked list?
A singly linked list nodes have one link to the next node only, while doubly linked list nodes have two links: one to the next node and one to the previous node, allowing backward traversal.
Click to reveal answer
intermediate
Why might you choose a singly linked list over an array?
A singly linked list allows easy insertion and deletion of nodes without shifting elements, and it can grow or shrink dynamically without needing a fixed size like arrays.
Click to reveal answer
What does each node in a singly linked list contain?
AData and references to next and previous nodes
BData and a reference to the next node
COnly data
DOnly a reference to the next node
✗ Incorrect
Each node contains data and a reference (link) to the next node only.
How do you know when you have reached the end of a singly linked list?
AWhen the node points back to the head
BWhen the data is null
CWhen the next reference is null
DWhen the previous reference is null
✗ Incorrect
The last node's next reference is null, indicating the end of the list.
Which operation is easier in a singly linked list compared to an array?
ASorting the elements
BAccessing an element by index
CRandom access
DInserting a new element in the middle
✗ Incorrect
Inserting in the middle is easier because you only change links without shifting elements.
What is the first node in a singly linked list called?
AHead
BTail
CRoot
DStart
✗ Incorrect
The first node is called the head.
Can you traverse a singly linked list backwards easily?
ANo, because nodes only link forward
BYes, by following previous links
CYes, by reversing the data
DNo, because it has no links
✗ Incorrect
Singly linked lists only have links to the next node, so backward traversal is not straightforward.
Explain the structure of a singly linked list and how nodes are connected.
Think about how each node points to the next one.
You got /4 concepts.
Describe the advantages of using a singly linked list compared to an array.
Consider how adding or removing elements works.
You got /4 concepts.
Practice
(1/5)
1. What does each node in a singly linked list contain?
easy
A. Only data without any pointers
B. Data and pointers to both next and previous nodes
C. Data and a pointer to the next node
D. Only a pointer to the previous node
Solution
Step 1: Understand node structure in singly linked list
Each node stores some data and a pointer to the next node only, not to the previous one.
Step 2: Compare options with definition
Data and a pointer to the next node matches the definition exactly. Data and pointers to both next and previous nodes describes a doubly linked list. Options C and D miss the pointer to the next node.
Final Answer:
Data and a pointer to the next node -> Option C
Quick Check:
Node = data + next pointer [OK]
Hint: Remember: singly linked means one pointer per node [OK]
Common Mistakes:
Confusing singly linked with doubly linked list
Thinking nodes have no pointers
Assuming pointer to previous node exists
2. Which of the following is the correct way to represent the head of a singly linked list in code?
easy
A. head = None
B. head = head.next
C. head = head.prev
D. head = data
Solution
Step 1: Understand the head pointer initialization
The head points to the first node or is None if the list is empty.
Step 2: Analyze options
head = None correctly initializes head as None for an empty list. head = head.next tries to move head to next node, which is invalid if list is empty. head = head.prev uses prev pointer which does not exist in singly linked list. head = data assigns data to head, which is incorrect.
head points to node1 with data 10. head.next points to node2 with data 20. head.next.next points to node3 with data 30.
Step 2: Identify the data at head.next.next
The data at node3 is 30.
Final Answer:
30 -> Option B
Quick Check:
head.next.next.data = 30 [OK]
Hint: Follow next pointers step-by-step [OK]
Common Mistakes:
Confusing node positions
Assuming next of last node is not None
Mixing data values with node references
4. Identify the error in this singly linked list insertion code snippet:
new_node = Node(data=5)
new_node.next = head
head = new_node.next
medium
A. new_node.next should be None
B. No error, code is correct
C. Data assignment to new_node is missing
D. head should be assigned to new_node, not new_node.next
Solution
Step 1: Understand insertion at head
To insert new_node at the start, new_node.next should point to current head, then head should be updated to new_node.
Step 2: Analyze the code error
The code sets new_node.next = head correctly, but then sets head = new_node.next, which points to old head, not new_node. This loses the new node as head.
Final Answer:
head should be assigned to new_node, not new_node.next -> Option D
Quick Check:
head = new_node after insertion [OK]
Hint: After linking, head must point to new_node [OK]
Common Mistakes:
Assigning head to new_node.next instead of new_node
Forgetting to link new_node.next to old head
Not updating head pointer after insertion
5. You want to reverse a singly linked list with nodes:
head -> node1 -> node2 -> node3 -> None
Which sequence of pointer changes correctly reverses the list?
hard
A. Change each node's next pointer to the previous node, then update head to last node
B. Swap data values between nodes without changing pointers
C. Set head to None and create a new list with reversed data
D. Change each node's next pointer to None
Solution
Step 1: Understand reversal of singly linked list
Reversing means changing each node's next pointer to point to the previous node instead of the next.
Step 2: Identify correct pointer update sequence
Change each node's next pointer to the previous node, then update head to last node correctly describes reversing pointers and updating head to the last node. Swap data values between nodes without changing pointers only swaps data, not pointers. Set head to None and create a new list with reversed data discards the list unnecessarily. Change each node's next pointer to None breaks links without reversing.
Final Answer:
Change each node's next pointer to the previous node, then update head to last node -> Option A
Quick Check:
Reverse = reverse pointers + update head [OK]
Hint: Reverse pointers, then reset head to last node [OK]
Common Mistakes:
Swapping data instead of pointers
Not updating head after reversal
Breaking links without reconnecting
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.