Performance analysis: time and space complexity, asymptotic notation and recurrence relations. - Question Bank
1. Consider the recurrence T(n) = 3T(n/3) + n. What is the time complexity?
2. Which scenario best describes an algorithm with O(2^n) time complexity?
3. What is the space complexity of a recursive function call stack if the maximum depth of recursion is 'n'?
4. If an algorithm has a time complexity of O(n log n), and the input size is multiplied by 16, how does the execution time change approximately?
5. Which of the following represents the tightest possible upper bound for the growth rate of a function?
6. What is the primary goal of performance analysis in algorithms?
7. What is the time complexity of inserting an element into a sorted array while maintaining the sorted order?
8. Which asymptotic notation is used to describe the upper bound of growth rate?
9. If T(n) = 4T(n/2) + n, what is the time complexity according to the Master Theorem?
10. Consider a function that doubles its input size in each recursive call, and the work done at each step is constant: T(n) = T(n/2) + O(1). This is solved by which Master Theorem case?
11. What is the space complexity of an algorithm that uses a fixed number of variables, regardless of input size?
12. What is the time complexity of finding the minimum element in an unsorted array?
13. Which of the following is a characteristic of Little o notation (o)?
14. What is the lower bound of the time complexity of any comparison-based sorting algorithm?
15. Which notation is used to denote the tight bound of an algorithm's growth rate?
16. If an algorithm's time complexity is O(n^3), and the input size increases from 10 to 20, by what factor does the execution time increase?
17. What does the recurrence T(n) = T(n/2) + O(1) represent?
18. Consider the recurrence T(n) = 2T(n/2) + O(1). What is its solution?
19. What is the time complexity of adding two numbers?
20. Which of the following describes an algorithm that performs a fixed number of operations regardless of the input size?
21. What is the time complexity of heap sort in the worst case?
22. What is the space complexity of quicksort (in-place implementation, ignoring recursion stack)?
23. What is the time complexity of quicksort in the worst case?
24. What is the time complexity of quicksort in the average case?
25. What is the space complexity of merge sort?
26. What is the time complexity of merge sort in the worst case?
27. What is the time complexity of bubble sort in the worst case?
28. Consider the recurrence T(n) = T(n-1) + O(n). What is its solution?
29. What is the space complexity of storing 'n' elements in a hash table?
30. What is the typical time complexity for inserting into a hash table?
31. Which of the following has the worst time complexity for searching?
32. What is the time complexity of deleting an element at the end of a singly linked list (without a tail pointer)?
33. What is the time complexity of inserting an element at the beginning of a singly linked list?
34. If T(n) = 2T(n/2) + O(n), what is the time complexity?
35. Which case of the Master Theorem applies when f(n) = Θ(n^(log_b a))?
36. The Master Theorem is used to solve which type of problems?
37. What does the recurrence relation T(n) = T(n-1) + O(1) typically represent?
38. Consider a loop that iterates 'n' times, and inside the loop, an operation takes O(n) time. What is the overall time complexity?
39. What is the space complexity of a recursive function that has a maximum recursion depth of 'd' and each call uses constant space?
40. What is the time complexity of binary search on a sorted array?
41. What is the time complexity of searching for an element in an unsorted array using linear search?
42. What is the time complexity of accessing an element in an array by its index?
43. Which of the following is NOT an example of an asymptotic notation?
44. What is the space complexity of an algorithm?
45. Consider an algorithm with a time complexity of O(n^2). If the input size doubles, how does the execution time approximately change?
46. Which asymptotic notation is typically used to express the worst-case time complexity?
47. Theta notation (Θ) provides:
48. Which of the following represents the best-case time complexity?
49. What does Big O notation primarily describe?