二进制搜索 [英] Binary search
本文介绍了二进制搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将二进制搜索用于2D数组?我想逐行搜索一个数字
How can I use binary search into 2D arrays?. I want to search a number row by row
推荐答案
二进制搜索仅在列表预先排序时有效。如何排序2D数组?
Binary search only works if the list is presorted. How is the 2D array ordered?
你好donbock。
2D数组已排序,我想逐行搜索,除此之外我想继续搜索即使找到了数字也许有另一个相同的数字,当搜索所有矩阵时,我想显示出现该数字的行。
我将不胜感激任何建议。 C ++如果有任何代码,谢谢。
Hi donbock.
The 2D array is sorted and I want to search a number by row, besides I want to continue the search even if the number is found maybe there is another same number and when the all matrix is searched I want to display the rows where that number appear.
I will appreciate any advice. C++ if there any code, thanks.
你好donbock。
我忘了告诉你2D数组中的行按升序排序。
Hi donbock.
I forgot to tell you that the rows into the 2D array are ordered ascending.
这篇关于二进制搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文