Binary search

برنامه‌نویسی 1 views

Persian equivalent جستجوی دودویی

In plain language Binary search checks the middle of a range and discards the half that cannot contain the answer.

Short definition It repeatedly halves a search interval over ordered values or a monotone predicate.

Detailed explanation and example

When looking for 12 in a sorted array, a midpoint value of 8 rules out the lower half. On a random-access array, the worst-case running time grows logarithmically.

Reference