10RANDOMIZATION
Think back to when we learned about binary search in Chapter 7. Rather than answering the question, “What is the optimal solution?” we instead asked, “Is this specific value the optimal solution?” While we were solving the Feeding Ants problem, you may have thought that my picking values out of thin air was outlandish, wondering how that was going to work at all. But it works great, as we now know.
You want something that’s even more outlandish than binary search? How about just straight-up guessing a completely random solution. How could that possibly work? What is it about specific problems that makes this random guessing a viable ...
Get Algorithmic Thinking, 2nd Edition 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.