Challenge: Recursion

Test your knowledge of recursion by solving this exercise.

Let's practice what we have learned so far.

Task

Suppose you are given a sorted array of nn distinct numbers that has been rotated kk steps for some unknown integer kk between 1 and nn. In other words, you are given an array A[1..n]A[1 .. n] such that some prefix A[1..k]A[1 .. k] is sorted in increasing order, the corresponding suffix A[k+1..n]A[k + 1 .. n] is sorted in increasing order, and A[n]<A[1]A[n] < A[1]. For example, you might be given the following element array (where k=10k = 10): 9 13 16 18 19 23 28 31 37 42 1 3 4 5 7 89 \ 13 \ 16 \ 18 \ 19 \ 23 \ 28 \ 31 \ 37 \ 42 \ 1 \ 3 \ 4 \ 5 \ 7 \ 8 ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy