4.3.4 Search Algorithms Flashcards

1
Q

Define an algorithm.

A

A set of instructions which completes a task in a finite time and always terminates.

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

Determine a search algorithm.

A

Finds the location of a certain item in a list or verifies that the item is in the list.

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

Outline the different types of search algorithms.

A

Linear, binary and a binary tree search.

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

Outline when a linear search is best used.

A

On any unordered list.

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

What is the time complexity of a linear search?

A

O(n)

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

What occurs in a linear search?

A

Each item is compared sequentially to the target.

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

When is a binary search best used?

A

On an ordered list.

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

What happens if a list is unordered, and you wish to use a binary search on it?

A

It must be sorted by a sorting algorithm.

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

What is the process of a binary search?

A

Looking at the midpoint in a list and determining if the target is higher or lower than the midpoint.

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

What is the time complexity of a binary search algorithm?

A

O(logN)

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

When is a binary search best conducted?

A

On any ordered binary tree.

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

What is a tree?

A

An acyclic, connected graph.

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

What is a binary tree?

A

A rooted, ordered tree in which each node has 0, 1, or 2 children.

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