grokking-algorithms/chapter1/ex1.2.py

8 lines
154 B
Python
Raw Normal View History

2023-12-19 03:41:10 +00:00
import math
num_steps = int(math.log2(128*2))
print(
f"A binary search would take maximum {num_steps} steps "
"to search a list of 256 items."
)