← Linked List Quiz: all 8 questions
Linked List Quiz · Question 2 of 8
When reversing a linked list, why do we save cur.next before changing cur.next = prev?
When reversing a linked list, why do we save cur.next before changing cur.next = prev?
- A.To count the nodes
- B.Otherwise we lose the rest of the list
- C.To make it faster
- D.To handle cycles
Answer & explanation
Correct answer: Otherwise we lose the rest of the list
Once cur.next points backwards, the only reference to the remaining nodes is the saved one.
Can you get the rest right without peeking?
Take the timed Linked List Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →