Where is binary search used in practice?

tjdonaldson picture tjdonaldson · Feb 12, 2009 · Viewed 39k times · Source

Every programmer is taught that binary search is a good, fast way to search an ordered list of data. There are many toy textbook examples of using binary search, but what about in real programming: where is binary search actually used in real-life programs?

Answer

Grey Panther picture Grey Panther · Feb 12, 2009

Binary search is used everywhere. Take any sorted collection from any language library (Java, .NET, C++ STL and so on) and they all will use (or have the option to use) binary search to find values. While true that you have to implement it rarely, you still have to understand the principles behind it to take advantage of it.