|
Search each record of the file one at a time until finding the given name and hence the corresponding record.
This method of searching for data in an array is straightforward and easy to understand. To find a given item, begin your search at the start of the data collection and continue to look until you have either found the target or exhausted the search space. Clearly to employ this method you must first know where the data collection begins and the size of the area to search. Alternatively, a unique value could be used to signify the end of the search space. This method of searching is most often used on an array data structure whose upper and lower bounds are known.
This type of search is complexity as, in the average case; one-half of the items in the search space will be examined before a match is found.
Binary Search:
Compare the given Name with the name in the middle of the list, list has which half of the list contains Name. Then compare Name with the name of the middle of the correct half to determine which quarter of the list contains the Name, continue the process until finding Name in the list.
|