跳转点算法
跳转搜索 (Jump Search)
A jump search locates an item in a sorted array by jumping k itens and then verify if the item wanted is between the previous jump and current jump.
跳转搜索通过跳转k itens在排序数组中查找项目,然后验证所需的项目是否在前一跳转和当前跳转之间。
复杂性最坏的情况 (Complexity Worst Case)
O(√N)
O(√N)
这个怎么运作 (How it works)
- Define the value of k, the number of jump: Optimal jump size is √N where the N is the length of array 定义跳跃值k的值:最佳跳跃大小为√N,其中N为数组的长度
Jump the array k-by-k searching by the condition
Array[i] < valueWanted < Array[i+k]
通过条件
Array[i] < valueWanted < Array[i+k]
跳搜索Array[i] < valueWanted < Array[i+k]
Do a linear search between
Array[i]
andArray[i + k]
在
Array[i]
和Array[i + k]
之间进行线性搜索
码 (Code)
To view examples of code implementation of this method access this link below:
要查看此方法的代码实现示例,请访问以下链接:
Jump Search - OpenGenus/cosmos
学分 (Credits)
翻译自: https://www.freecodecamp.org/news/jump-search-algorithm-explained/
跳转点算法