Improve grammar for this README.md (#21419)

Clarify and add more detail to the steps of doing Jump Search.
This commit is contained in:
Siddhartha Anand
2018-11-12 21:22:49 +05:30
committed by Niraj Nandish
parent bc896c92ea
commit 8d8dff86f3

View File

@ -3,21 +3,21 @@ title: Jump Search
--- ---
## Jump Search ## 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 A jump search locates an item in a sorted array by jumping k items in the array and then verifies if the item wanted is between the previous jump and current jump.
the previous jump and current jump.
# Complexity Worst Case # Worst Case Complexity
O(√N) O(√N)
# Works # How does it work ?
1. Define the value of k, the number of jump: Optimal jump size is √N where the N is the length of array 1. Define the value of k, the number of jumps: The optimal jump size is √N where N is the length of the sorted array.
2. Jump the array k-by-k searching by the condition `Array[i] < valueWanted < Array[i+k]` 2. Jump over the array elements by k everytime, checking the following condition `Array[i] < valueWanted < Array[i+k]`.
3. Do a linear search between `Array[i]` and `Array[i + k]` 3. If the previous condition is true, then do a linear search between `Array[i]` and `Array[i + k]`.
4. Return the position of the value if it is found in the array.
![Jumping Search 1](https://i1.wp.com/theoryofprogramming.com/wp-content/uploads/2016/11/jump-search-1.jpg?resize=676%2C290) ![Jumping Search 1](https://i1.wp.com/theoryofprogramming.com/wp-content/uploads/2016/11/jump-search-1.jpg?resize=676%2C290)
# Code # Code
To view examples of code implementation of this method access this link below: To view examples of code implementation for this method, access this link below:
[Jump Search - OpenGenus/cosmos](https://github.com/OpenGenus/cosmos/tree/master/code/search/jump_search) [Jump Search - OpenGenus/cosmos](https://github.com/OpenGenus/cosmos/tree/master/code/search/jump_search)