Grokking the Art of Recursion for Coding Interviews
Ask Author
Back to course home

0% completed

9. Binary Search
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Write Recursive Approach to Implement Binary Search Algorithm.

The problem is to implement the binary search algorithm using recursion. Given a sorted array and a target key, the algorithm should determine whether the key is present in the array or not.

Examples

Sr #ArrayInput KeyOutput
1[1, 2, 3, 4, 5]4True
2[2, 4, 6, 8, 10]5False
3[3, 6, 9, 12, 15]15True

Constraints:

  • 1 <= nums.length <= 10<sup>4</sup>

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible