Quidest?

binary search algorithm

ยท Lorenzo Drumond

A binary search algorithm is a common example of an O(log(n)) algorithm. Binary searches work on a sorted list of elements.

Pseudocode

Given an array of n elements sorted from least to greatest, and a target value:

Because at each iteration of the search we are halving the size of the search space, the algorithm has a complexity of log2, or O(log(n)).

In other words, to add another step to the runtime, we need to double the size of the input. Binary searches are fast.

References

Next -> bubble-sort-algorithm

#notation #boot_dev #computer_science #algorithm #big_o #binary_search #programming