🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.To count the nodes
  2. B.Otherwise we lose the rest of the list
  3. C.To make it faster
  4. 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 →