Lecture 9 Searching
Lecture 9 Searching
Searching Algorithms
Necessary components to search a list of data
◦ Array containing the list
◦ Length of the list
◦ Item for which you are searching
Best case
Average Number of
1 + 2 + 3 + …..+ N + N
=
Comparisons
N+1
Worst case and key is NOT found!
Number of possible cases
Binary Search Algorithm
complete
Binary Search Algorithm (Cont’d)
• Determine whether 75 is in the list
17
Advantages of a linear search