Time and Space Complexity Flashcards

Focus on the complexity analysis of different algorithms and data structures.

1
Q

What is Omega (Ω) Notation?

A

Omega Notation describes the lower bound of the time complexity of an algorithm. It gives the best-case scenario, or the minimum time required by an algorithm.

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

What is Theta (Θ) Notation?

A

Theta Notation tightly bounds the time complexity of an algorithm. It represents the exact upper and lower bounds of the time required for the algorithm.

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

Time Complexity of Common Sorting Algorithms

A

Bubble Sort: O(n^2)
Quick Sort: Average - O(n log n), Worst - O(n^2)
Merge Sort: O(n log n)
Insertion Sort: Average - O(n^2), Best - O(n)

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

What algorithms and patterns are suitable for an input size of 10 (10^1)?

A

Time Complexity: O(n!)
Problems: Permutations, Traveling Salesman Problem, Exhaustive Search
Patterns: Backtracking, Brute Force
Algorithms: Permutation Generation, Hamiltonian Cycle

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

What algorithms and patterns are suitable for an input size of 100 (10^2)?

A

Time Complexity: O(n³)
Problems: Smaller Dynamic Programming Problems, Dense Graphs
Patterns: Dynamic Programming, Graph Algorithms
Algorithms: Floyd-Warshall, Subset Sum

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

What algorithms and patterns are suitable for an input size of 1000 (10^3)?

A

Time Complexity: O(n²)
Problems: Medium Dynamic Programming Problems, Basic Sorting
Patterns: Dynamic Programming, Divide and Conquer
Algorithms: Bubble Sort, Insertion Sort, Selection Sort

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

What algorithms and patterns are suitable for an input size of 10000 (10^4)?

A

Time Complexity: O(n log n) / O(n√n)
Problems: Larger Sorting, Efficient Graph Algorithms
Patterns: Divide and Conquer, Greedy Algorithms
Algorithms: Merge Sort, Quick Sort, Heap Sort

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

What algorithms and patterns are suitable for an input size of 100000 (10^5)?

A

Time Complexity: O(n log n) / O(n)
Problems: Large Scale Sorting, Segment Trees, Efficient Graph Traversal
Patterns: Greedy Algorithms, Graph Theory
Algorithms: Merge Sort, Quick Sort, Dijkstra’s Algorithm

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

What algorithms and patterns are suitable for an input size of 1000000 (10^6)?

A

Time Complexity: O(n) / O(log n)
Problems: Linear Searches, Binary Searches, Simple Loops
Patterns: Searching and Traversal, Graph Theory
Algorithms: Linear Search, Binary Search, BFS, DFS

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

How do you calculate the number of digits in n = 1000?

A

Use the formula d = floor(log10(n)) + 1. For n = 1000, log10(1000) = 3, so d = 3 + 1 = 4. Therefore, 1000 has 4 digits.

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

What is the time complexity of the logarithmic relationship in algorithms that process each digit of a number?

A

For algorithms that involve operations on each digit of a number (like summing digits), the time complexity is O(log n). This is because the number of operations is tied to the number of digits, which grows logarithmically with the size of the number.

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