哪里是在实践中使用二进制搜索?是在、实践中

2023-09-10 23:54:26 作者:厌心

每个程序员教导了二分搜索是搜索数据的顺序列表的好,快速的方法。有使用二进制搜索很多玩具课本上的例子,但如何在真正的编程:哪里是在现实生活中的方案实际使用二进制搜索

解决方案

二分查找时的到处 的。任取有序集合任何语言库(Java,.NET,C ++ STL等),他们都将使用(或必须使用该选项)二进制搜索找到的值。虽然如此,你必须很少实现它,你还是要理解背后的原理是利用它的优势。

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?

解决方案

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.