3.1.3 - Searching algorithms Flashcards

(8 cards)

1
Q

Linear search

A

A linear search checks each item in a list one by one until the desired item is found or the end of the list is reached.​

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

Binary search

A

A binary search repeatedly divides a sorted list in half to find the desired item more efficiently.

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

What are the advantages of a linear search?

A

Works on unsorted lists
No need for complex algorithms​

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

What are the disadvantages of a linear search?

A

Can be slow for large lists
Inefficient compared to binary search on sorted data

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

What are the advantages of a binary search?

A

Faster than linear search for large, sorted lists

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

What are the disadvantages of a binary search?

A

Requires the list to be sorted
More complex to implement than linear search

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

When is a linear search more appropriate than a binary search?

A

When dealing with small or unsorted lists

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

When is a binary search more appropriate than a linear search?

A

When dealing with large, sorted lists where search efficiency is important.​

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