Searching Algorithms 4
Searching Algorithms 4
Lesson Objectives:
At the end of this lesson, you will be able to:
• Learn what is searching algorithm.
• Identify the categories of searching algorithm.
• Analysed different searching algorithm.
TWO CATEGORIES
1. SEQUENTIAL SEARCH
The list or array is traversed sequentially and every element is
checked.
ALGORITHM
OUTPUT
2. INTERVAL SEARCH
• These algorithms are specifically designed for searching in sorted data-structures. These type of
searching algorithms are much more efficient than Linear Search as they repeatedly target the center of
the search structure and divide the search space in half.
• Binary search is a fast search algorithm with run-time complexity of Ο(log n). This search algorithm
works on the principle of divide and conquer. For this algorithm to work properly, the data collection
should be in the sorted form.
• Binary search looks for a particular item by comparing the middle most item of the collection. If a match
occurs, then the index of item is returned. If the middle item is greater than the item, then the item is
searched in the sub-array to the left of the middle item. Otherwise, the item is searched for in the sub-
array to the right of the middle item. This process continues on the sub-array as well until the size of the
subarray reduces to zero.
OUTPUT
JUMP SEARCH
ALGORITHM
SUMMARY
• Searching Algorithms are designed to check for an element or retrieve an element from any data
structure where it is stored.
• In sequential search the list or array is traversed sequentially and every element is checked.
• In interval search algorithms are specifically designed for searching in sorted data-structures. These type
of searching algorithms are much more efficient than Linear Search as they repeatedly target the center
of the search structure and divide the search space in half.
• Binary search looks for a particular item by comparing the middle most item of the collection