Examples of the use of two types of different search algorithms, namely: sequential search and binary search. When data items are stored in a collection, such as a list, we say that they have a linear or sequential relationship. Each data item is stored in a position relative to the others.
Binary Search
If you have a list with the values ordered numerically or alphabetically, it is possible to do a much faster search. Instead of searching the list in sequence, a binary search will begin by examining the item in the middle. If that item is the one we're looking for, the search ends. If it is not the correct item, we can use the ordered nature of the list to eliminate half of the remaining items. If the item we are looking for is larger than the middle item, we know that the entire lower half of the list, as well as the middle item, can be eliminated from further consideration. The item, if it is on the list, must be in the top half.
Sequential Search
This method consists of scanning the entire vector for the information the user wants, as it is very slow and takes up a lot of memory, this method has fallen out of use. Remembering that this implemented algorithm is just one of the many ways to do the linear search.