Algorithms Flashcards

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

Linear Search Definition

A

Works by comparing the search item with the first value and then comparing the search item with the second value. This process is repeated until either the end of the data set is reached or the search item is found

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

Linear Search Advantages

A
  • Can perform fast searches of small data sets
  • Not affected by insertions and deletions as the linear search doesn’t require the list to be sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Linear Search Disadvantages

A
  • Inefficient for large data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Linear Search Suitability

A
  • Small data set
  • Data set isn’t sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Binary Search Definition

A

Works by starting at the middle item of the data set and repeatedly dividing the list in half until either the item is found pr the entire data set is searched

Precondition - Data set must be sorted first

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

Binary Search Advantages

A
  • Efficiently searches large data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Binary Search Suitability

A
  • Large data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Binary Search Time Complexity

A

Best - O(1)
Average - O(n)
Worst - O(n)

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

Linear Search Time Complexity

A

Best - O(1)
Average - O(log n)
Worst - O(log n)

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