stella v0.4.0 BinarySearch

Documentation for Binary search algorithm

Annotations

  • n - number of elements in list

Link to this section Summary

Functions

Find number in list and return it index. Requires as input sorted list.

Link to this section Functions

Link to this function

run(list, searched_value)

Find number in list and return it index. Requires as input sorted list.

  • Time complexity: O(log2n)
  • Memory complexity: O(1)

Examples

iex> BinarySearch.run([-1, 2, 3.00000001, 4], 3.00000001)
2

iex> BinarySearch.run([0, 0, 0, 0, 1, 2, 3, 4], 0)
3