Add binary-search module: iterative/recursive search, overflow-safe midpoint, lowerBound/upperBound, rotated arrays, search on the answer, 10 interview problems (14 tests, 14 transcripts)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b3tGdV3Vm51QUZxg2x
This commit is contained in:
Claude
2026-11-22 19:47:36 +05:30
parent 3336e2ba15
commit ce12a80f58
39 changed files with 2110 additions and 0 deletions
@@ -0,0 +1,20 @@
Iterative binary search, traced step by step on [10, 20, 30, 40, 45]
====================================================================
search for 40
low=0 high=4 mid=2 a[mid]=30 -> 40 > 30, low=3
low=3 high=4 mid=3 a[mid]=40 -> equals 40, return 3
result: 3 (position 4 counting from 1), 2 elements compared
search for 10
low=0 high=4 mid=2 a[mid]=30 -> 10 < 30, high=1
low=0 high=1 mid=0 a[mid]=10 -> equals 10, return 0
result: 0 (position 1 counting from 1), 2 elements compared
search for 25
low=0 high=4 mid=2 a[mid]=30 -> 25 < 30, high=1
low=0 high=1 mid=0 a[mid]=10 -> 25 > 10, low=1
low=1 high=1 mid=1 a[mid]=20 -> 25 > 20, low=2
low=2 high=1 -> low > high, return -1
result: -1, 3 elements compared