Time & Space Complexity Flashcards

1
Q

What is the time complexity of sorting an array with Quick Sort?

A

Average O(n log n), Worst O(n²).

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

What is the best-case and worst-case time complexity of Merge Sort?

A

Average O(n log n), Worst O(n²).

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

What is the time complexity of inserting an element into a balanced BST?

A

O(n log n) for best, worst, and average case.

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

What is the worst-case time complexity of searching in a hash table?

A

O(n) (if all keys collide).

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

What is amortized time complexity?

A

Cost averaged over multiple operations.

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

What is the difference between O(log n) and O(n log n)?

A

Logarithmic (e.g., binary search) vs. log-linear (e.g., sorting).

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

What is Big O Notation

A

Describes worst-case runtime growth rate.

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