6.2 Searching Algorithms Flashcards

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

Give 2 searching algorithms for lists or arrays

A

Binary

Linear

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

Binary search requirements

A

Must have a sorted list

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

How does a binary search work?

A

The middle item of a list is first checked
If the item is greater than the node your are looking for, it will loom on the left side, otherwise on the right side.
This process keeps happening untill the searching node becomes a midpoint

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

How does a liner search work?

A

Each item is checked against the search item in order (ie iteration, but list order does not matter)

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

In a list of 2^n items, what will be the maximum items you will have to search for in a binary search?

A

n+1

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