Big O Flashcards

1
Q

What does time complexity describe?

A

The amount of computational time an algorithm takes

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

What is the focus of Big-O notation?

A

Worst-case scenarios

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

List the order of functions from fast to slow in Big-O notation.

A
  • O(1) Constant
  • O(log(n)) Logarithmic
  • O(logc(n)) Polylogarithmic
  • O(n) Linear
  • O(n log(n)) Linearithmic/Loglinear
  • O(n²) Quadratic
  • O(n² log(n))
  • O(n³) Polynomial
  • O(2ⁿ) Exponential
  • O(n!) Factorial
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is O(1) in Big-O notation?

A

Constant

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

What is O(log(n)) in Big-O notation?

A

Logarithmic

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

What does O(n) represent in Big-O notation?

A

Linear

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

What does O(n log(n)) represent?

A

Linearithmic/Loglinear

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

What is the Big-O notation for a quadratic function?

A

O(n²)

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

What is the Big-O notation for exponential growth?

A

O(2ⁿ)

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

What is the Big-O notation for factorial growth?

A

O(n!)

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

What properties do we ignore in Big-O notation?

A

Coefficients and log bases

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

When adding functions, what Big-O notation do we take?

A

The slowest function’s Big-O

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

When multiplying functions, what do we take in Big-O notation?

A

The product of the functions’ Big-O

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

What is the average/typical Big-O for Bubble sort?

A

Θ(n²), O(n²)

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

What is the average/typical Big-O for Quick sort?

A

Θ(n log(n)), O(n²)

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

What is the average/typical Big-O for Merge sort?

A

Θ(n log(n)), O(n log(n))

17
Q

What is the average/typical Big-O for Radix sort?

A

Θ(n), O(n)

18
Q

True or False: A loop in a loop is O(n²).

19
Q

True or False: A loop in a loop in a loop is O(n).

20
Q

Fill in the blank: If the number of steps stays the same no matter how large, then it’s _______.

21
Q

Fill in the blank: If you go through a n long list linearly, then you’ll take at most _______.

22
Q

Fill in the blank: A pseudocode loop that divides n by 2 repeatedly is _______.

23
Q

What does the notation f(x) ∈ O(g(x)) indicate?

A

f(x) is a collection of functions that grows at most as fast as g(x)

24
Q

What is the Big-O performance for Algorithm 1?

25
Q

What is the Big-O performance for Algorithm 2?

26
Q

What is the Big-O performance for Algorithm 3?

27
Q

What is the Big-O performance for Algorithm 4?

A

O(n log n)

28
Q

What is the Big-O performance for Algorithm 5?