2.3.4 - Searching Algorithms Flashcards

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

What is a search algorithm?

A

An algorithm used to find a specified element within a data structure.

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

How does a binary search work?

A

It works by finding the middle element in a list of data before deciding which side of the data the desired element is to be found in. The unwanted half is then discarded and the process is repeated until the desired element is found.

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

What needs to be done before doing a binary search?

A

The list needs to be sorted.

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

What is the time complexity of a binary search algorithm?

A

O (log n).

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

How does a linear search work?

A

It searches through each element in an array until the desired search criteria is found.

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

What is the time complexity of a linear search algorithm?

A

O (n).

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