Daa Sample Questions of Co-1 and Co-2

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

CO1

1. Distinguish between Recursive algorithm and Non-Recursive algorithm with an


example. (4.5M)
2. Write an algorithm to find factorial of a given number using both iterative and recursive
method. (4.5M)
3. Solve the recurrence relations. (8M)
(i). x (n) = x (n-1) + 5 for n>1.
(ii). X (n) = X(n/3) +1 for n >1,x(1) =1. (Solve for n = 3k)
4. Demonstrate tower of Hanoi algorithm for n=5 discs. (Recursive Tree) (8M)
5. Sort the following elements 62, 71, 88, 93, 12, 14, 56, 75, 89, 23, 55, 12, 66, 87, 54, 11, 33,
42, 77 and 7 using merge sort. Show the order of elements after completion of final pass.
6. Write a divide and conquer algorithm for Finding the minimum and maximum from an array
and also derive the time complexity.
Calculate time and space complexity for the following algorithm using Theta notation.
Algorithm Fib(n)
{
If((n=0) or (n=1)) then
Return n;
Else
{
F1:=0;F2:=3; i:=3;
While(i<=n)
{ F:=F1 + F2;
F1:=F2; F2:=F;
i:=i+1;
}
Return F;
}
CO2
7 Apply Greedy method to find an optimal solution to the knapsack instance n=7, m=15,
(p1,p2,p3,p4,p5,p6,p7) = (10,5,15,7,6,18,3) & ( w1 , w2 , w3 , w4,w5,w6,w7) = (2,3,5,7,1,4,1) and
also write the algorithm . (4.5M)
8 Give the general procedure of Greedy Method and analyze the key terms of feasibility and
optimization? (4.5M)
9 Construct a minimal spanning tree for the following graph using Prim’s algorithm.
(8M)
10 Construct minimum cost spanning tree using Kruskal’s algorithm for the following graph.
(8M)

11. Apply Greedy method to find an optimal solution generated by the job
sequencing with deadlines when n=7, (P1, P2, P3, P4, P5, P6, P7) = (3, 5, 20, 18, 1,
6, 30) & (D1, D2, D3, D4, D5, D6, D7) = (1, 3, 4, 3, 2, 1, 2)?
(8M)
12. Find boundary points for convex hull for the given set of points: {(-7,8), (-4,6), (2,6), (6,4), (8,6), (7,-
2), (4,-6), (8,-7),(0,0),(3,-2),(6,-10),(0,-6),(-9,-5),(-8,-2),(-8,0),(-10,3),(-2,2),(-10,4)} using Graham
Scan Algorithm
13 A networking company uses a compression technique to encode the message before
transmitting over the network. Suppose the message contains the following characters with
their frequency:

Note that each character in input message takes 1 byte. If the compression technique used is
Huffman Coding, how many bits will be saved in the message?

You might also like