Data Structures & AlgorithmsModerate

How many DISTINCT strings are produced by all cyclic rotations of "abcabc" (including the identity rotation)?

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

Correct answer: B. 3

Rotations by 0 to n−1 give n strings, but periodic strings repeat, so count the distinct ones. Here the period is 3, so only three distinct rotations exist.

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

Exams that ask this topic