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?
- A. 6
- B. 7
- C. 8
- 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
- Bellman–Ford is run from A on the directed graph A→B 4, A→C 2, C→B 1, B→D 5, C→D 8, D→E 3, C→E 10, E→F −2, D→F 6. In each pass the edges…
- Assume P ≠ NP. Which of the following problems have a polynomial-time algorithm? I. 2-SAT. II. 3-colourability of a graph. III. Maximum…
- A polynomial-time many-one reduction from problem A to problem B is given (A ≤ₚ B). Which statements must be true? I. If B ∈ P then A ∈ P…
- Median-of-medians selection with groups of 7 satisfies T(n) ≤ T(n/7) + T(5n/7) + cn (ignore floors). Guessing T(n) ≤ an, what is the…
- Consider T(n) = 2T(n/2) + n/log₂²n for powers of 2, T(1) = 1. Which is the tight asymptotic bound?
- T(n) = 4T(n/2) + n² log₂ n. Which is the tight solution?