GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Floyd's cycle-finding is applied to the sequence x₀ = 2, x_{i+1} = (x_i² + 1) mod 55. How many distinct values does the sequence take?

  1. A. 6
  2. B. 7
  3. C. 8
  4. D. 9

Correct answer: C. 8

The sequence is 2, 5, 26, 17, 15, 6, 37, 50, and then 50² + 1 = 2501 ≡ 26 (mod 55) returns to 26. The tail has 2 values (2, 5) and the cycle 6 values, so 8 distinct values in all; Floyd's method detects μ = 2 and λ = 6.

More Algorithms questions

Exams that ask this topic