




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which notation provides an upper bound for the growth rate of a function in algorithm analysis? A) Big Omega (Ω) B) Big Theta (Θ) C) Big O (O) D) Little o (o) Answer: C Explanation: Big O notation gives an upper bound on the growth rate, describing the worst-case scenario for an algorithm’s complexity. Question 2. What does the Master Theorem solve? A) Asymptotic notation B) Recurrence relations
C) Sorting algorithms D) Linked list operations Answer: B Explanation: The Master Theorem provides a straightforward way to solve recurrence relations commonly found in divide-and-conquer algorithms. Question 3. Which case represents the slowest performance for an algorithm? A) Best-case B) Average-case C) Worst-case D) Expected-case Answer: C
A) Master Theorem B) Substitution Method C) Recursion Tree D) Backtracking Answer: B Explanation: The Substitution Method involves making an educated guess and mathematically proving it using induction. Question 6. What does the Big Omega (Ω) notation represent? A) Upper bound B) Lower bound C) Tight bound D) Average-case
Answer: B Explanation: Big Omega (Ω) gives a lower bound on the growth rate of a function. Question 7. Which recurrence relation represents the merge sort algorithm? A) T(n) = T(n-1) + O(1) B) T(n) = 2T(n/2) + O(n) C) T(n) = T(n/3) + O(1) D) T(n) = T(n-1) + T(n-2) Answer: B Explanation: Merge sort splits the problem into two halves and merges them, leading to T(n) = 2T(n/2) + O(n).
D) O(n log n) Answer: C Explanation: Linear search may have to check each element, resulting in O(n) time in the worst case. Question 10. Which of the following is NOT a method for solving recurrence relations? A) Substitution Method B) Recursion Tree C) Master Theorem D) Quick Sort Answer: D Explanation: Quick Sort is a sorting algorithm, not a method for solving recurrences.
Question 11. What is the result of the summation ∑_{i=1}^n i? A) n B) n² C) n(n+1)/ D) n(n-1)/ Answer: C Explanation: The sum of the first n natural numbers is n(n+1)/2. Question 12. In algorithm analysis, what does the average-case refer to? A) The best possible input B) The slowest input C) The expected running time over all inputs
Question 14. Which of the following is a floor function? A) ⌈x⌉ B) ⌊x⌋ C) x/x D) x² Answer: B Explanation: The floor function ⌊x⌋ returns the greatest integer less than or equal to x. Question 15. What is the recurrence relation for binary search? A) T(n) = T(n-1) + 1 B) T(n) = T(n/2) + O(1)
C) T(n) = 2T(n/2) + O(n) D) T(n) = T(n) + 1 Answer: B Explanation: Binary search splits the problem in half each time, resulting in T(n) = T(n/2) + O(1). Question 16. Which asymptotic notation provides a tight bound? A) O B) Ω C) Θ D) o Answer: C Explanation: Θ notation gives an exact asymptotic bound.
B) T(n) = Θ(n^log_b(a)) C) T(n) = Θ(f(n)) D) T(n) = Θ(n) Answer: A Explanation: Case 2 of the Master Theorem applies when f(n) matches n^log_b(a), adding a log n factor. Question 19. Which of the following is NOT true about Big O notation? A) It gives a tight bound B) It gives an upper bound C) It ignores constant factors D) It is used in worst-case analysis Answer: A
Explanation: Big O gives an upper, not necessarily tight, bound. Question 20. What is the time complexity of merge sort? A) O(n) B) O(n log n) C) O(n²) D) O(log n) Answer: B Explanation: Merge sort divides and merges, resulting in O(n log n) time complexity. Question 21. Which sort algorithm is NOT comparison-based? A) Merge Sort
Question 23. Which property does stable sorting ensure? A) Minimum time complexity B) Preserves order of equal elements C) Uses less memory D) Always O(n log n) Answer: B Explanation: Stable sorting keeps equal elements in their original relative order. Question 24. What is the best-case time complexity of quick sort? A) O(n) B) O(n²)
C) O(n log n) D) O(log n) Answer: C Explanation: Best-case quick sort splits evenly, making O(n log n) comparisons. Question 25. Which sorting algorithm is guaranteed to run in O(n log n) time in the worst case? A) Merge Sort B) Quick Sort C) Bubble Sort D) Selection Sort Answer: A
A) O(n²) B) O(n+k) C) O(n log n) D) O(log n) Answer: B Explanation: Counting sort runs in O(n + k), where k is the range of the input. Question 28. Which sorting algorithm is NOT in-place? A) Heap Sort B) Quick Sort C) Merge Sort D) Selection Sort
Answer: C Explanation: Merge sort requires extra space for merging. Question 29. What is the main advantage of radix sort? A) Works well with negative numbers B) Stable and non-comparison based C) O(n²) time D) Works only for small arrays Answer: B Explanation: Radix sort is stable, non-comparison based, and efficient for large numbers with small digit sizes.