Data Structures and Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the Jump Search algorithm?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Time Complexity of the Jump Search algorithm?

A

O(sqrt(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the optimal “jump size” (or k) in the Jump Search algorithm?

A

sqrt(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What primary advantage does Jump Search have over Binary Search?

A

You only have to jump back one time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Linear Search algorithm?

A

A search algorithm for any array that checks each element individually. Usually from left to right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Time Complexity of the Linear Search algorithm?

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two classes of search algorithms?

A

Sequential - each element is checked once.

Interval - subsets of the elements are checked leveraging the fact that the collection is sorted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Binary Search algorithm?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Time Complexity of the Binary Search algorithm?

A

O(log(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Interpolation Search algorithm?

A

A modification of binary search that uses linear interpolation to use the midpoint.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In what scenario is Interpolation Search advantageous over Binary Search?

A

In data sets that are relatively uniformly distributed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the position formula for Interpolation Search?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly