Skip to content

Commit 4741115

Browse files
Improve binary search documentation by adding basic explanation.
1 parent 678dedb commit 4741115

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

searches/binary_search.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
"""
44
Pure Python implementations of binary search algorithms
55
6+
Basic Idea:
7+
Binary Search works by repeatedly dividing the search interval in half.
8+
If the target value is smaller than the middle element, the search continues
9+
in the left half. Otherwise, it continues in the right half.
10+
This process repeats until the element is found or the interval becomes empty.
11+
612
For doctests run the following command:
713
python3 -m doctest -v binary_search.py
814
915
For manual testing run:
1016
python3 binary_search.py
1117
"""
1218

19+
1320
from __future__ import annotations
1421

1522
import bisect

0 commit comments

Comments
 (0)