Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
Nodes 0 to 10 form a linked structure where each node i points to node (2*i + 1) mod 11. Starting at node 0, how many distinct nodes lie on the cycle that is eventually entered?
- A. 11
- B. 1
- C. 20
- D. 10
Correct answer: D. 10
From 0: 0→1→3→7→4→9→8→6→2→5→0, a cycle of 10 that starts at the start node (no tail). Node 10 maps to itself, so the cycle cannot contain all 11 nodes; 1 is that separate fixed point, and 20 is the number of fast-pointer moves before Floyd's pointers meet.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Tasks are (duration, deadline): (4, 2), (2, 1), (3, 2), (1, 1), (5, 3), and a single machine runs them one at a time from time 0. What is…
- What is the sum of gcd(a, b) over all unordered pairs of distinct elements of [6, 10, 15]?
- How many contiguous subarrays of [2, 4, 2, 1, 3] have a sum exactly equal to twice their maximum?
- With coins of denominations 1, 5, 6 and 9, what is the minimum number of coins needed to make the amount 15?
- Including the empty prefix (sum 0), how many of the prefix sums of [3, 1, 4, 2, 6, 5, 3, 1] are divisible by 4?
- How many distinct residues modulo 7 are produced by x y for x and y ranging over {2, 3, 4} (all ordered pairs, including x = y)?