Analysis of Algorithms Flashcards

1
Q

List the order of algorithm big O complexities from best to worst

A

O(1) < O(logn) < O(n) < O(nlogn) < O(n2) < O(n3) <O(2n) < O(n!)

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

For a binary search, what is the complexity?

A

O(log n), this is because the array is sorted

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

For linear search, what is the complexity?

A

O(n), this is because we are searching through the entire array.

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

What are the main criteria for comparing algorithms?

A
  1. Conceptual simplicity
  2. Difficulty to implement
  3. Difficulty to modify
  4. Running time
  5. Memory usage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Space Complexity?

A

The amount of memory/storage required by an algorithm during its execution

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

What is Time Complexity?

A

How much time an algorithm takes to execute based on the size of input?

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