Professional Documents
Culture Documents
Search Algorithms
Suppose that there are n elements in the array. The following expression gives the average number of comparisons:
It is known that
Therefore, the following expression gives the average number of comparisons made by the sequential search in the successful case:
Search Algorithms
Binary Search
Binary search algorithm assumes that the items in the array being searched are sorted
Binary Search
mid =
left + right 2
11
Binary Search
12
Binary Search
13
14
If desired, the recursive version of the method search can be converted to an iterative version that will run more efficiently
15