Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 为什么可以';我们在跳转搜索中使用二进制搜索而不是线性搜索吗?_Algorithm_Search - Fatal编程技术网

Algorithm 为什么可以';我们在跳转搜索中使用二进制搜索而不是线性搜索吗?

Algorithm 为什么可以';我们在跳转搜索中使用二进制搜索而不是线性搜索吗?,algorithm,search,Algorithm,Search,以下文章介绍了跳转搜索: 最后一步是线性搜索。 如果数组已经排序并且二进制搜索的时间复杂度为log(n),而线性搜索的时间复杂度为n,那么为什么我们不能使用二进制搜索呢?跳转搜索的用例(O(√n) )而不是二进制搜索(O(logn))是指跳回的代价很高。在这方面,在跳转搜索中替换线性搜索将适得其反。您能否详细说明跳转成本更高的场景?“跳回是昂贵的”指的是更多的缓存未命中吗?@Shubham我们可能是从旋转介质中读取的,在旋转介质中,向前扫描是便宜的,而随机搜索是昂贵的。

以下文章介绍了跳转搜索:

最后一步是线性搜索。
如果数组已经排序并且二进制搜索的时间复杂度为log(n),而线性搜索的时间复杂度为n,那么为什么我们不能使用二进制搜索呢?

跳转搜索的用例(O(√n) )而不是二进制搜索(O(logn))是指跳回的代价很高。在这方面,在跳转搜索中替换线性搜索将适得其反。

您能否详细说明跳转成本更高的场景?“跳回是昂贵的”指的是更多的缓存未命中吗?@Shubham我们可能是从旋转介质中读取的,在旋转介质中,向前扫描是便宜的,而随机搜索是昂贵的。