Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

How many distinct cyclic rotations does the string abcabc have (rotations are the strings obtained by moving a prefix to the end, including the identity)?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 6

Correct answer: B. 3

Rotations starting at i and i+3 coincide because the string has period 3, so only 3 distinct rotations remain. Counting all six index shifts overcounts.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic