Sample Paper Daa
Sample Paper Daa
Q1: Apply the coin problem with regards to the following data: Input: sum = 15,
coins [] = {1, 2, 3, 4}
Q2: Construct an optimal binary search tree for the following Five–key set
Key A B C D E
0.2 0.3 0.4 0.5 0.6
Probability
Q3: A file contains the following characters with the frequencies as shown. If
Huffman Coding is used for data compression, determine-
1. Average code length
2. Length of Huffman encoded message (in bytes)
Characters Frequencies
h 1
e 1
l 3
o 2
w 1
r 1
d 1
Q4: Find an optimal solution to the 0/1, knapsack problem given the knapsack
capacity in W=10 using dynamic programming
Item Weight Value
1 3 $13
2 3 $22
3 3 $15
4 3 $20
Q5: Solve the activity selection problem using the greedy approach for the
followings set of activities: Set of activities, A = Start time S = <0, 1, 3, 4, 5, 7>
Finish time F = <4, 5, 4, 7, 9, >
Q6: Illustrate the all-pair shortest path problem algorithm. And calculate the all-
pair shortest path problem for the digraph
with the weighted matrix given below:
a b c d
a 2 α 6 2
b 3 3 α α
c α 9 4 1
d 6 7 α 5
Q7: Explain the concept of Matrix Chain Multiplication with the example: The
matrices have sizes 5 x 7, 7 x 3, 3 x 9, 9 x 10, and 10 x 7. We know M [i, i] = 0
for all i.