Data Structures & AlgorithmsHard

Count the CIRCULAR descents of 3 4 5 1 2: positions i (0 ≤ i < n) where A[i] > A[(i+1) mod n], with the last element compared to the first. What is the count?

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

Correct answer: A. 1

A circular array that is a rotation of a sorted array has exactly one circular descent, so this count tests rotation. Ignoring the wrap-around pair, adding one, or counting ascents instead changes the value.

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

Exams that ask this topic