Appendix. Answers to Exercises
Chapter 1
Suppose you have a sorted list of 128 names, and you’re searching through it using binary search. What’s the maximum number of steps it would take?
7.
Suppose you double the size of the list. What’s the maximum number of steps now?
8.
You have a name, and you want to find the person’s phone number in the phone book.
O(log n).
You have a phone number, and you want to find the person’s name in the phone book. (Hint: You’ll have to search through the whole book!)
O(n).
You want to read the numbers of every person in the phone book. ...
Get Grokking Algorithms now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.