Searching Algorithms Flashcards
What is sequential search?
Sequential search, or linear search, is a method for finding a particular value in a list that checks each element in sequence until the desired element is found or the list is exhausted. The list need not be ordered. The best case for sequential search is that it does one comparison, and matches X right away. In the worst case, sequential search does n comparisons, and either matches the last item in the list or doesn’t match anything.
What is binary search?
A binary search, or half-interval search, halves the number of items to check with each iteration, so locating an item (or determining its absence) takes logarithmic time.
Best case: O(1)
Worst case: O(log n)
What is hashing?
Hashing is a type of search in which a function is used to give the index of a stored value.