Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 439 Bytes

09-BinarySearch.md

File metadata and controls

15 lines (11 loc) · 439 Bytes

Binary Search

The problem

Write a function f(N, M) that accepts a number array N and a key M and return true if the key is present in the array and false if it is not.

  • use recursion

Concepts

  • Recursion
    • a function calling itself
    • must have a base case that returns a value instead of calling itself again
  • values being searched must be sorted

Note

  • very popular and common algorithm due to O(log n) complexity