Challenge: Recursion

Test your knowledge of recursion by solving this exercise.

We'll cover the following...

Let's practice what we've learned so far.

Logic building

In order to solve part (a) of the problem, we’ll first begin by analyzing the algorithm below. After that, we’ll move on to coding implementation.

(a) Algorithm to compute kk:

  • Initialize two pointers, left and right, to the beginning and end of the array, respectively (left=0,right=n1left = 0, right = n - 1).
  • While left<rightleft < right:
    • Calculate the middle index: mid=(left+right)//2mid = (left + right) // 2
...