Big O Flashcards

(46 cards)

1
Q

What is O(1) complexity called?

A

Constant time complexity

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

Give an example of O(1) complexity.

A

Accessing an array element by index

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

What is O(log n) complexity called?

A

Logarithmic time complexity

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

Give an example of O(log n) complexity.

A

Binary search

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

What is O(n) complexity called?

A

Linear time complexity

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

Give an example of O(n) complexity.

A

Linear search through a list

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

What is O(n log n) complexity called?

A

Linearithmic time complexity

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

Give an example of O(n log n) complexity.

A

Merge sort or quick sort (average case)

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

What is O(n²) complexity called?

A

Quadratic (a type of polynomial) time complexity

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

Give an example of O(n²) complexity.

A

Bubble sort or insertion sort in the worst case

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

What is O(2ⁿ) complexity called?

A

Exponential time complexity

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

Give an example of O(2ⁿ) complexity.

A

Naive recursive Fibonacci algorithm

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

Which Big O graph is flat, unaffected by input size?

A

O(1) Constant

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

Which Big O graph rises slowly and flattens?

A

O(log n) Logarithmic

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

Which Big O graph is a straight diagonal line?

A

O(n) Linear

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

Which Big O graph is steeper than linear but less than quadratic?

A

O(n log n) Linearithmic

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

Which Big O graph curves steeply upwards as n increases?

A

O(n²) Quadratic

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

Which Big O graph shoots up almost vertically?

A

O(2ⁿ) Exponential

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

Linear search best case complexity?

20
Q

Linear search average case complexity?

21
Q

Linear search worst case complexity?

22
Q

Binary search best case complexity?

23
Q

Binary search average case complexity?

24
Q

Binary search worst case complexity?

25
Binary search tree best case complexity?
O(1)
26
Binary search tree average case complexity?
O(log n)
27
Binary search tree worst case complexity?
O(n)
28
Hashing best case complexity?
O(1)
29
Hashing average case complexity?
O(1)
30
Hashing worst case complexity?
O(n)
31
Bubble sort best case complexity?
O(n)
32
Bubble sort average case complexity?
O(n²)
33
Bubble sort worst case complexity?
O(n²)
34
Insertion sort best case complexity?
O(n)
35
Insertion sort average case complexity?
O(n²)
36
Insertion sort worst case complexity?
O(n²)
37
Merge sort best case complexity?
O(n log n)
38
Merge sort average case complexity?
O(n log n)
39
Merge sort worst case complexity?
O(n log n)
40
Quick sort best case complexity?
O(n log n)
41
Quick sort average case complexity?
O(n log n)
42
Quick sort worst case complexity?
O(n²)
43
What is 'best case' complexity?
The fewest steps an algorithm could take on an input
44
What is 'worst case' complexity?
The maximum steps an algorithm could take on an input
45
What is 'average case' complexity?
The expected steps an algorithm would take on a typical input
46
Why do we usually focus on worst case in Big O?
Because it guarantees performance regardless of input