Binary Search and Jump Search
2.Binary Search:
Search a list by repeatedly dividing the search interval in half. Start with a interval that covers the entire list. If the search key value is less than the mid item, reduce the interval to the lower part. Otherwise reduce it to the upper part. Check again until the value is found or the interval is empty.
Binary search algorithm :-
STEP 1:- Compare x with the middle item.
STEP 2:- If x is the same as the middle object, we return the middle index.
STEP 3:- Alternatively if the x is larger than the center object, then x can only lie in the sub array of the right half after the middle object. So we multiply the right half.
STEP 4:- In some cases (x less) it goes back to the left side
Time Complexity:- O(log n)
3.Jump search:-
Like Binary Search, Jump Search is a search algorithm for sorted arrays. The basic idea is to look for a element by skipping a fixed number of elements rather than traversing through all the elements.
Algorithm of jump search :-
Let us consider the following list: (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610). The length is 16. Jump search will find a value of 55 in the following steps assuming that the block size will be skipped or jumped by 4.
STEP 1: Jump from point 0 to point 4;
STEP 2: Jump from boat 4 to boat 8;
STEP 3: Jump from boat 8 to boat 12;
STEP 4: Since the item in index 12 is greater than 55 we will come to index 8.
STEP 5: Perform direct search from index 8 to find item 55.
Time Complexity:- O(√ n)


Easy to understand siddhi
ReplyDeletenice work
Very well Explained!!!
ReplyDeleteGreat content...
ReplyDeleteHelpful content
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWell Explained!
ReplyDeletegood work. keep it up. all the best
ReplyDelete