diff --git a/chapter1/ex1.1.py b/chapter1/ex1.1.py new file mode 100644 index 0000000..613ddd8 --- /dev/null +++ b/chapter1/ex1.1.py @@ -0,0 +1,7 @@ +import math + +num_steps = int(math.log2(128)) +print( + f"A binary search would take maximum {num_steps} steps " + "to search a list of 128 items." +) diff --git a/chapter1/ex1.2.py b/chapter1/ex1.2.py new file mode 100644 index 0000000..aa80532 --- /dev/null +++ b/chapter1/ex1.2.py @@ -0,0 +1,7 @@ +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." +)