|
|
Line 1: |
Line 1: |
| In [[computer science]], a '''jump search''' or '''block search''' refers to a [[search algorithm]] for [[list (computing)|ordered lists]]. It works by first checking all items ''L''<sub>''km''</sub>, where <math>k \in \mathbb{N}</math> and ''m'' is the block size, until an item is found that is larger than the [[search key]]. To find the exact position of the search key in the list a [[linear search]] is performed on the [[sublist]] ''L''<sub>[(''k''-1)''m'', ''km'']</sub>.
| | I would like to introduce myself to you, I am Jayson Simcox but I don't like when people use my complete name. Her family [http://si.dgmensa.org/xe/index.php?document_srl=48014&mid=c0102 free online tarot card readings] members life in Ohio but her spouse desires them to move. Office supervising is exactly where my main earnings comes from but I've usually wanted my own company. online psychic reading - [http://netwk.hannam.ac.kr/xe/data_2/85669 http://netwk.hannam.ac.kr/xe/data_2/85669] - As a lady what she truly likes is fashion and she's been doing it for fairly a whilst.<br><br>Also visit my blog post email psychic readings ([http://formalarmour.com/index.php?do=/profile-26947/info/ formalarmour.com]) |
| | |
| The optimal value of ''m'' is √''n'', where ''n'' is the length of the list ''L''. Because both steps of the [[algorithm]] look at, at most, √''n'' items the algorithm runs in O(√''n'') time. This is better than a [[linear search]], but worse than a [[binary search]]. The advantage over the latter is that a jump search only needs to jump backwards once, while a binary can jump backwards up to log ''n'' times. This can be important if a jumping backwards takes significantly more time than jumping forward.
| |
| | |
| The algorithm can be modified by performing multiple levels of jump search on the sublists, before finally performing the [[linear search]]. For an ''k''-level jump search the optimum block size ''m''<sub>''l''</sub> for the ''l''<sup>th</sup> level (counting from 1) is ''n''<sup>(k-l)/k</sup>. The modified algorithm will perform ''k'' backward jumps and runs in O(''kn''<sup>1/(''k''+1)</sup>) time.
| |
| | |
| ==Implementation==
| |
| '''Algorithm''' JumpSeach
| |
| Input: An ordered list ''L'', its length ''n'' and a search key ''s''.
| |
| Output: The position of ''s'' in ''L'', or '''nothing''' if ''s'' is not in ''L''.
| |
|
| |
| ''a'' ← 0
| |
| ''b'' ← ⌊√''n''⌋
| |
|
| |
| '''while''' ''L''<sub>min(''b'',''n'')-1</sub> < ''s'' '''do'''
| |
| ''a'' ← ''b''
| |
| ''b'' ← ''b'' + ⌊√''n''⌋
| |
| '''if''' ''a'' ≥ ''n'' '''then'''
| |
| '''return''' '''nothing'''
| |
|
| |
| '''while''' ''L''<sub>''a''</sub> < ''s'' '''do'''
| |
| ''a'' ← ''a'' + 1
| |
| '''if''' ''a'' = min(''b'',''n'')
| |
| '''return''' '''nothing'''
| |
|
| |
| '''if''' ''L''<sub>''a''</sub> = ''s'' '''then'''
| |
| '''return''' ''a''
| |
| '''else'''
| |
| '''return''' '''nothing'''
| |
| | |
| ==See also==
| |
| * [[Jump list]]
| |
| * [[Interpolation search]]
| |
| * [[Linear search]] - runs in O(''n'') time, only looks forward
| |
| * [[Binary search]] - runs in O(log ''n'') time, looks both forward and backward
| |
| | |
| ==References== | |
| * {{DADS|jump search|jumpsearch}}
| |
| * [[Ben Shneiderman]], ''Jump Searching: A Fast Sequential Search Technique'', CACM, 21(10):831-834, October 1978.
| |
| | |
| [[Category:Search algorithms]]
| |
I would like to introduce myself to you, I am Jayson Simcox but I don't like when people use my complete name. Her family free online tarot card readings members life in Ohio but her spouse desires them to move. Office supervising is exactly where my main earnings comes from but I've usually wanted my own company. online psychic reading - http://netwk.hannam.ac.kr/xe/data_2/85669 - As a lady what she truly likes is fashion and she's been doing it for fairly a whilst.
Also visit my blog post email psychic readings (formalarmour.com)