同步操作将从 Gitee 极速下载/javascript-algorithms 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Like Binary Search, Jump Search (or Block Search) is a searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements.
For example, suppose we have an array arr[]
of size n
and block (to be jumped)
of size m
. Then we search at the indexes arr[0]
, arr[m]
, arr[2 * m]
, ..., arr[k * m]
and
so on. Once we find the interval arr[k * m] < x < arr[(k+1) * m]
, we perform a
linear search operation from the index k * m
to find the element x
.
What is the optimal block size to be skipped?
In the worst case, we have to do n/m
jumps and if the last checked value is
greater than the element to be searched for, we perform m - 1
comparisons more
for linear search. Therefore the total number of comparisons in the worst case
will be ((n/m) + m - 1)
. The value of the function ((n/m) + m - 1)
will be
minimum when m = √n
. Therefore, the best step size is m = √n
.
Time complexity: O(√n)
- because we do search by blocks of size √n
.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。