Gujarat Technological University
Gujarat Technological University
: ________ Enrolment
No.___________
(b) Explain an algorithm for Selection Sort Algorithm. Derive its best case, worst case 07
and average case time complexity.
Q.2 (a) Write the Prim’s Algorithm to find out Minimum Spanning Tree. Apply the same 07
and find MST for the graph given below.
(b) What is recurrence? Solve recurrence equation T (n) =T (n-1) + n using forward 07
substitution and backward substitution method.
OR
(b) Sort the given elements with Heap Sort Method: 20, 50, 30, 75, 90, 60, 25, 10, 40. 07
Q.3 (a) Write Huffman code algorithm and Generate Huffman code for following 07
Letters A B C D E
Frequency 24 12 10 8 8
07
(b) Write an algorithm for quick sort and derive best case, worst case using divide and
conquer technique also trace given data (3,1,4,5,9,2,6,5)
OR
Q.3 (a) Write equation for Chained matrix multiplication using Dynamic programming. 07
Find out optimal sequence for multiplication:
A1 [5 × 4], A2 [4 × 6], A3 [6 × 2], and A4 [2 × 7]. Also give the optimal
parenthesization of matrices.
(b) Using greedy algorithm find an optimal schedule for following jobs with n=6. 07
Profits: (P1,P2,P3,P4,P5,P6) = (20, 15, 10, 7, 5, 3)
Deadline: (d1,d2,d3,d4,d5,d6) =(3, 1, 1, 3, 1, 3)
1
Q.4 (a) Explain Depth First Traversal Method for Graph with algorithm with example. 07
(b) Explain how to find out Longest Common Subsequence of two strings using 07
Dynamic Programming method. Find any one Longest Common Subsequence of
given two strings using Dynamic Programming.
X=abbacdcba
Y=bcdbbcaac
OR
Q.4 (a) Explain Breath First Traversal Method for Graph with algorithm with example. 07
(b) Solve Making Change problem using Dynamic Programming. (Denominations: 07
d1=1, d2=4, d3=6). Give your answer for making change of Rs. 9.
Q.5 (a) Explain Backtracking Method. What is N-Queens Problem? Give solution of 4- 07
Queens Problem using Backtracking Method.
(b) What is Finite Automata? Explain use of finite automata for string matching with 07
suitable example.
OR
Q.5 (a) Define P, NP, NP complete and NP-Hard problems. Give examples of each. 07
(b) Give and explain Rabin-Carp string matching algorithm with example. 07
*************