Data Structures & AlgorithmsHard

The sorted array 2 5 8 11 13 17 21 was rotated so that it now reads 13 17 21 2 5 8 11. At which 0-based index is the value 11?

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

Correct answer: C. 6

The rotated array keeps two sorted halves; locate the pivot (the smallest element) and the target in the correct half. The index of the target in the rotated array is what the question asks, not its sorted rank.

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

Exams that ask this topic