Skip to content

Commit c660e00

Browse files
committed
Checkpoint for possible future talk.
1 parent 0b731f5 commit c660e00

10 files changed

+15
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

presentations/2025-04-28-are-we-there-yet/code.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,18 @@ int* binary_search_insert_position(int* first, int* last, int x) {
2020
}
2121
return first;
2222
}
23+
24+
int binary_search(int x[], int n, int v) {
25+
int l = 0;
26+
int u = n - 1;
27+
28+
while (true) {
29+
if (l > u) return -1;
30+
31+
int m = (l + u) / 2;
32+
33+
if (x[m] < v) l = m + 1;
34+
else if (x[m] == v) return m;
35+
else /* (x[m] > v) */ u = m - 1;
36+
}
37+
}
1.13 MB
Binary file not shown.
2.28 MB
Binary file not shown.

0 commit comments

Comments
 (0)