DAA Question Bank
DAA Question Bank
DAA Question Bank
𝑇 𝑛 = 𝑇 𝑛−1 +𝑛 , 𝑛≥1
0 𝑛=0
𝑇 𝑛 = 2𝑇 𝑛 − 1 + 1 , 𝑛≥1
0 𝑛=0
3𝑇 𝑛/2 + 𝑛 , 𝑛≥1
𝑇 𝑛 =
0 𝑛=0
𝑛
𝑇 𝑛 = 2𝑇 +𝑛, 𝑛>1
2
1 𝑛=1
3. Solve the following recurrences using master method.
𝑛
i) 𝑇 𝑛 = 9𝑇 +𝑛
43
2𝑛
ii) 𝑇 𝑛 =𝑇 +1
3
𝑛
iii) 𝑇 𝑛 = 2𝑇 +𝑛
2
𝑛
iv) 𝑇 𝑛 = 3𝑇 + 𝑛𝑙𝑔𝑛
4
𝑛
v) 𝑇 𝑛 = 4𝑇 + 𝑛^3
2
𝑓 𝑛 = 3𝑛 + 7
𝑓 𝑛 = 5𝑛2 + 8𝑛 + 2
𝑓 𝑛 = 27𝑛2 + 16𝑛
𝑓 𝑛 = 3𝑛3 + 4𝑛 + 2
𝑓 𝑛 = 4𝑛3 + 2𝑛 + 3
𝑓 𝑛 = 5𝑛3 + 8𝑛2 + 2𝑛 + 4
𝑓 𝑛 = 5𝑛5 + 8𝑛4
6. Prove or disprove the followings:
1. Write down the algorithm of Mergesort and Merge procedure. Find its
complexity.
2. Write down the algorithm of Quicksort and Partition procedure. Find its
complexity.
3. Find an optimal parenthesization of matrix chain multiplication whose sequence
of dimension is <30, 35, 15, 5, 10, 20, 25>
4. Find an optimal parenthesization of matrix chain multiplication whose sequence
of dimension is <5,10,20,30,40>
5. Find an optimal parenthesization of matrix chain multiplication whose sequence
of dimension is <5,10,20,30,40>
6. Write down the algorithm for computing the length of an LCS. Find LCS from
the given sequence X={A,B,C,B,D,A,B} and Y={B,D,C,A,B,A}
7. Write down the algorithm for computing the length of an LCS. Find LCS from
the given sequence X={a,b,b,b,a,a,b,a} and Y={a,b,a,a,b,a,a,b}
8. Write down the algorithm for computing the length of an LCS. Find LCS from
the given sequence X={1,0,0,1,0,1,0,1} and Y={0,1,0,1,1,0,1,1,0}
9. Given a list of activities along with the start time and finishing times
<1,3>,<2,5>,<3,4>,<4,7>,<7,10>,<8,9>,<9,11>,<9,13>,<11,12>,<12,14>
Compute a schedule where the largest number of activities takes place.
10.Given a list of activities along with the start time and finishing times
<1,4>,<3,5>,<0,6>,<5,7>,<3,8>,<5,9>,<6,10>,<8,11>,<8,12>,<2,13>,<12,14>
Compute a schedule where the largest number of activities takes place.