Clifford A. Shaffer[1997] define searching as
a process to determine whether an element is a member of a certain data set
External search
only implemented if searching is done on a very large size of data. Half of the data need to be processed in RAM while half of the data is in the secondary storage.
Internal search
searching technique that is implemented on a small size of data. All datacan be load into RAM while the searching process is conducted.
Basic Sequential Search
• usually to search item from unsorted list/array
• small size
• low effiecieny
• every element in array will be examine sequentially
• repeated until last element of array or until data is found
• used for searching that involves record stored in the main memory (RAM)
• simple but slowest search algorithm
Basic Sequential Searching Strategy
• Examines element in array sequentially and compared with the search key
• Search successful if key matches with compared value in array
• Search process terminated
• if no matches found, search continue until last element of array
• Search failed if no matches found from array
Sequential search drawback
Having to traverse the entire list, O(n)
Binary search algorithm\ Worse case
Log2 n
How binary search algorithm works
- search process started at the middle of the list
- then algorithm determine which half the is in
- repeat
Binary search best case
search key found in first middle array, O(1)
Worse case for binary search
search key is not in the list or searching size equal to 1