Algorithm Analysis and Complexity Flashcards

1
Q

What is time complexity

A

a measure of how an algorithms runtime grows with input size.

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

What is Big-O notation?

A

A mathematical notation describing an algorithm’s worst-case growth rate.

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

What are common time complexities from best to worst?

A

O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ) < O(n!).

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

What does Big-O notation describe?

A

The upper bound of an algorithm’s growth rate (worst-case performance).

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

What is Omega (Ω) notation?

A

The lower bound of an algorithm’s growth rate (best-case performance).

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

What is Theta (Θ) notation?

A

The tight bound—both the upper and lower bounds of an algorithm’s growth rate.

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

What is amortized complexity?

A

The average time per operation over a sequence of operations (e.g., resizing an array-based dynamic list).

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

Give an example of an algorithm with O(1) time complexity.

A

Hash table lookup (assuming no collisions).

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

What is an invariant in algorithms?

A

A property that remains true at each step of execution (used in loop invariants).

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

How do you prove an algorithm is correct?

A

Using induction or loop invariants.

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