DAA PracticeProblems Module-1
DAA PracticeProblems Module-1
2. For each of the following functions, indicate how much the function's value will change if its argument is
increased fourfold:
(i) log2n (ii) √n (iii) n (iv) n2 (v) n3 (vi) 2n
3. Write a recursive algorithm to solve the tower of Hanoi problem. Set up and solve recurrence relation
using backward substitution method.
4. Write the pseudocode to find the GCD of two numbers using consecutive integer method. Compute the
best case and worst-case time complexity of this algorithm.
5. Given an array of integers, write a recursive algorithm to find the smallest element in it. Set up a
recurrence relation for number of element comparisons made in this algorithm and solve it.
6. Prove that: 2n + 2n logn ≠ O(2n)
7.
8.
12. Prove or disprove the following equalities using the formal definition of the corresponding asymptotic
notation and also using limits theorem:
13. Derive the time complexity recurrence relation for the following code and solve it using substitution
method. Also find the space complexity for the same.
14. Analyse best, worst and average case complexities using step count method and also find space
complexity for the following code snippet: