Algorithm QA Set2
Algorithm QA Set2
- Time Complexity: Measures the amount of time an algorithm takes based on input size.
Ascending order: 1 < log(n) < n < n*log(n) < n^2 < n^3 < 2^n < n!
4. Pick the odd one out: Insertion Sort, Merge Sort, Quick Sort. Justify your answer.
Justification: It is an in-place, comparison-based algorithm suitable for small or nearly sorted datasets, while Merge Sort
A mobile digit in algorithms like Johnson-Trotter is a digit that can move (i.e., swap) in its current direction and is greater
6. What are the time complexities of Matrix multiplication and Strassen's Matrix multiplication?
A hash function maps keys to array indices. Hashing is used for fast data retrieval, insertion, and deletion in constant
time on average.
8. What is the major difference between Divide and Conquer and Decrease and Conquer?
Divide and Conquer divides the problem into multiple subproblems (e.g., Merge Sort).
Decrease and Conquer reduces the problem to a smaller version of itself (e.g., Insertion Sort).
For small datasets like this, Insertion Sort is best due to its simplicity and efficiency on nearly sorted or small-sized
inputs.
Dynamic Programming is a method for solving complex problems by breaking them down into simpler overlapping
MST (Minimum Spanning Tree): A subset of edges in a connected, weighted graph that connects all vertices with the