
Implement a function that locates key in an increasing sequence you can only read one element at a time through the callback at, spending at most 24 reads.
binary_search(7, 8, at) over {2, 4, 6, 8, 10, 12, 14}idx=3 probes<=24binary_search(5, 3, at) over {1, 3, 3, 3, 5}idx=1 probes<=24binary_search(7, 9, at) over {2, 4, 6, 8, 10, 12, 14}idx=-1 probes<=24binary_search(1000000, 1999998, at) with at(i) = i * 2idx=999999 probes<=24the same call, answered by reading index 0, then 1, then 2, and so onidx=999999 probes=1000000binary_search.c<stddef.h>defines size_t
Run the tests to grade your code
Implement a function that locates key in an increasing sequence you can only read one element at a time through the callback at, spending at most 24 reads.
binary_search(7, 8, at) over {2, 4, 6, 8, 10, 12, 14}idx=3 probes<=24binary_search(5, 3, at) over {1, 3, 3, 3, 5}idx=1 probes<=24binary_search(7, 9, at) over {2, 4, 6, 8, 10, 12, 14}idx=-1 probes<=24binary_search(1000000, 1999998, at) with at(i) = i * 2idx=999999 probes<=24the same call, answered by reading index 0, then 1, then 2, and so onidx=999999 probes=1000000binary_search.c<stddef.h>defines size_t
Run the tests to grade your code
Memory will appear here