Performance Analysis - time and space complexities, asymptotic notation, recurrence relations - Question Bank
1. Which of the following is an example of an algorithm with O(n log n) time complexity?
2. Which of the following is an example of an algorithm with O(1) time complexity?
3. What does T(n) = Θ(n^2) imply about the algorithm's runtime?
4. What does T(n) = Ω(n^2) imply about the algorithm's runtime?
5. What does T(n) = O(n^2) imply about the algorithm's runtime?
6. Which of the following is NOT a standard asymptotic notation used in performance analysis?
7. The Master Theorem can be used to solve recurrence relations of the form T(n) = aT(n/b) + f(n) where a >= 1, b > 1. Which condition corresponds to the solution T(n) = Θ(n^(log_b a))?
8. The Master Theorem can be used to solve recurrence relations of the form T(n) = aT(n/b) + f(n) where a >= 1, b > 1. Which condition corresponds to the solution T(n) = Θ(f(n))?
9. The Master Theorem can be used to solve recurrence relations of the form T(n) = aT(n/b) + f(n) where a >= 1, b > 1. Which condition corresponds to the solution T(n) = Θ(n^log_b a)?
10. Consider the recurrence relation T(n) = 2T(n/2) + n^2. What is its solution using the Master Theorem?
11. Consider the recurrence relation T(n) = 4T(n/2) + n. What is its solution using the Master Theorem?
12. Consider the recurrence relation T(n) = T(n/2) + c. What is its solution?
13. Consider the recurrence relation T(n) = 2T(n/2) + n. What is its solution using the Master Theorem (assuming n is a power of 2)?
14. Which of the following is a typical base case for a recurrence relation?
15. What is the primary use of recurrence relations in algorithm analysis?
16. If f(n) = 3n^2 + 2n + 1 and g(n) = n^2, then f(n) is Θ(g(n)). Is this statement true or false?
17. If f(n) = 2n + 5 and g(n) = n, then f(n) is Θ(g(n)). Is this statement true or false?
18. If f(n) = n and g(n) = n^2, then f(n) is O(g(n)). Is this statement true or false?
19. If f(n) = n^2 and g(n) = n, then f(n) is Ω(g(n)). Is this statement true or false?
20. What does 'Little omega' (ω) notation represent?
21. What does 'Little o' (o) notation represent?
22. What is the space complexity of an algorithm that uses an auxiliary array of size n?
23. What is the space complexity of an algorithm that sorts an array of n elements in-place (e.g., Heap Sort)?
24. What is the space complexity of a recursive function that has a maximum recursion depth of k?
25. Consider the following C code snippet: `int i = n; while (i > 0) { i /= 2; }`. What is its time complexity?
26. Consider the following C code snippet: `int i = 1; while (i < n) { i *= 2; }`. What is its time complexity?
27. Consider the following C code snippet: `for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { /* constant time operation */ } }`. What is its time complexity?
28. What is the Big O complexity of linear search on an unsorted array of n elements?
29. What is the Big O complexity of binary search on a sorted array of n elements?
30. What is the Big O complexity of an algorithm that iterates through a list of n elements using nested loops, where each loop runs n times?
31. What is the Big O complexity of an algorithm that iterates through a list of n elements once?
32. Which growth rate is faster: O(log n) or O(n)?
33. Which growth rate is faster: O(n^2) or O(n log n)?
34. If T(n) is Θ(f(n)), which of the following is true?
35. What does Big Theta (Θ) notation signify?
36. If an algorithm's runtime is T(n) = n log n + 5n, what is its Big O complexity?
37. If an algorithm's runtime is T(n) = 2^n + n^3, what is its Big O complexity?
38. If an algorithm's runtime is T(n) = 100, what is its Big O complexity?
39. If an algorithm's runtime is T(n) = 5n + 20, what is its Big O complexity?
40. If an algorithm's runtime is T(n) = 3n^2 + 5n + 10, what is its Big O complexity?
41. Which asymptotic notation provides a tight bound (both upper and lower) on the growth rate of a function?
42. Which asymptotic notation provides a lower bound on the growth rate of a function?
43. Which asymptotic notation provides an upper bound on the growth rate of a function?
44. What does 'average-case' complexity refer to in algorithm analysis?
45. What does 'worst-case' complexity refer to in algorithm analysis?
46. What does 'best-case' complexity refer to in algorithm analysis?
47. Which measure quantifies the amount of time an algorithm takes to run?
48. Which measure quantifies the amount of memory an algorithm uses?
49. What is the primary goal of performance analysis in algorithms?