🎙 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 4 of 8

Floyd's cycle detection uses…

Floyd's cycle detection uses…

  1. A.A hash set of visited nodes
  2. B.A slow pointer (1 step) and a fast pointer (2 steps)
  3. C.Sorting the nodes
  4. D.Recursion
Answer & explanation

Correct answer: A slow pointer (1 step) and a fast pointer (2 steps)

If there's a cycle, the fast pointer eventually meets the slow one; otherwise it reaches null. O(1) space.

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 →