I know how binary search works but I wanted to know practical uses for binary search... I searched through the internet and I found that the main use is data base indexing,but I couldn't understand how binary search could help in data base indexing.
我知道二进制搜索是如何工作的,但我想知道二进制搜索的实际用途......我通过互联网搜索,发现主要用途是数据库索引,但我无法理解二进制搜索如何帮助数据库索引。
4 个解决方案
#1
3
Binary search allows you to quickly look up a record by its key, assuming the keys are already sorted. This is especially true if the number of keys is large. 32 key reads would be sufficient to find any single unique key within a collection of two billion sorted keys.
二进制搜索允许您通过其键快速查找记录,假设键已经排序。如果键的数量很大,则尤其如此。 32个密钥读取足以在20亿个排序密钥的集合中找到任何单个唯一密钥。
Binary search works this way because each search attempt cuts the number of records to search in half.
二进制搜索以这种方式工作,因为每次搜索尝试都会将要搜索的记录数量减少一半。
That said, databases typically use some other binary tree-like data structure such as b-trees or red-black trees to perform the indexing. Using a binary tree removes the requirement that the list of keys be sorted before searching.
也就是说,数据库通常使用一些其他二叉树状数据结构(如b树或红黑树)来执行索引。使用二叉树删除了在搜索之前对键列表进行排序的要求。
#2
0
Any time you have a sorted list you can use binary search to efficiently search through the list. Database indexes are data structures of sorted data.
只要有排序列表,就可以使用二进制搜索来有效搜索列表。数据库索引是排序数据的数据结构。
#3
0
while I was looking for the solution, found a very useful link, also an answer for your question.
当我在寻找解决方案时,找到了一个非常有用的链接,也是你问题的答案。
Using Binary trees in Table Database indexes.
在表数据库索引中使用二叉树。
#4
0
Binary search computes next position (middle point) on each step.
二进制搜索计算每一步的下一个位置(中间点)。
DB's Binary tree precompute the middle point on each step, until reaching the single item. populate all the middle points to a tree. when do querying, DBMS looks up the tree.
DB的二叉树预先计算每一步的中间点,直到达到单个项目。将所有中间点填充到树中。什么时候查询,DBMS查找树。
#1
3
Binary search allows you to quickly look up a record by its key, assuming the keys are already sorted. This is especially true if the number of keys is large. 32 key reads would be sufficient to find any single unique key within a collection of two billion sorted keys.
二进制搜索允许您通过其键快速查找记录,假设键已经排序。如果键的数量很大,则尤其如此。 32个密钥读取足以在20亿个排序密钥的集合中找到任何单个唯一密钥。
Binary search works this way because each search attempt cuts the number of records to search in half.
二进制搜索以这种方式工作,因为每次搜索尝试都会将要搜索的记录数量减少一半。
That said, databases typically use some other binary tree-like data structure such as b-trees or red-black trees to perform the indexing. Using a binary tree removes the requirement that the list of keys be sorted before searching.
也就是说,数据库通常使用一些其他二叉树状数据结构(如b树或红黑树)来执行索引。使用二叉树删除了在搜索之前对键列表进行排序的要求。
#2
0
Any time you have a sorted list you can use binary search to efficiently search through the list. Database indexes are data structures of sorted data.
只要有排序列表,就可以使用二进制搜索来有效搜索列表。数据库索引是排序数据的数据结构。
#3
0
while I was looking for the solution, found a very useful link, also an answer for your question.
当我在寻找解决方案时,找到了一个非常有用的链接,也是你问题的答案。
Using Binary trees in Table Database indexes.
在表数据库索引中使用二叉树。
#4
0
Binary search computes next position (middle point) on each step.
二进制搜索计算每一步的下一个位置(中间点)。
DB's Binary tree precompute the middle point on each step, until reaching the single item. populate all the middle points to a tree. when do querying, DBMS looks up the tree.
DB的二叉树预先计算每一步的中间点,直到达到单个项目。将所有中间点填充到树中。什么时候查询,DBMS查找树。