Data Structures and Algorithms Flashcards
What is the Jump Search algorithm?
A search algorithm for sorted arrays that makes jumps of size k (1 <= k < n) to find which block (of size k) the element being searched for would potentially exist in. Then a linear search is done through that block for the element.
What is the Time Complexity of the Jump Search algorithm?
O(sqrt(n))
What is the optimal “jump size” (or k) in the Jump Search algorithm?
sqrt(n)
What primary advantage does Jump Search have over Binary Search?
You only have to jump back one time.
What is the Linear Search algorithm?
A search algorithm for any array that checks each element individually. Usually from left to right.
What is the Time Complexity of the Linear Search algorithm?
O(n)
What are the two classes of search algorithms?
Sequential - each element is checked once.
Interval - subsets of the elements are checked leveraging the fact that the collection is sorted.
What is the Binary Search algorithm?
A search algorithm for sorted arrays that recursively checks a middle value and then decides which half of the interval to search by comparing that middle value with the search term.
What is the Time Complexity of the Binary Search algorithm?
O(log(n))
What is the Interpolation Search algorithm?
A modification of binary search that uses linear interpolation to use the midpoint.
In what scenario is Interpolation Search advantageous over Binary Search?
In data sets that are relatively uniformly distributed.
What is the position formula for Interpolation Search?
m = L + [(x - A[L]) * (R - L) / (A[R] - A[L])]
m = midpoint L = left interval bound R = right interval bound A = the array being searched x = the search term