简体   繁体   English

在单个链接列表上进行二进制搜索

[英]binary search on a single linked list

How do I perform a binary search on a single linked list headed ? 如何在标题为单个的链表上执行二进制搜索? Also it can do it , if there is any particular method. 如果有任何特定的方法,它也可以做到。 The EP can not tell in advance how many elements of that list , I have to search and enter a cell between q > prox and p . EP无法预先告知该列表中有多少元素,我必须搜索并输入q> prox和p之间的单元格。

Typically this is not possible, since binary search requires random access, and a singly-linked list can only provide forward sequential access. 通常这是不可能的,因为二进制搜索需要随机访问,而单链接列表只能提供前向顺序访问。 Without being able to jump around in memory and look at some nth element (either through direct random-access or a skip list), we end up being required to linearly search through the list from beginning to end even if it's sorted. 由于无法在内存中跳转并查看nth元素(通过直接随机访问或跳过列表),因此最终要求我们对列表进行从头到尾的线性搜索,即使它是经过排序的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM