Gujarat Technological University
Gujarat Technological University
/Seat No_______________
Marks
Q.1 (a) Define the following terms: 03
i) Function in mathematics ii) Linear inequalities
(b) Explain the need of amortized notation. Explain with suitable example. 04
(c) Write an algorithm for insertion sort. Calculate the best, average and worst 07
case complexity of it.
Q.3 (a) Explain the steps of greedy strategy for solving a problem. 03
(b) Write an algorithm for Max-Min problem using divide and conquer 04
approach. Calculate its complexity.
(c) The matrices A(5X10), B(10X15), C(15X20), and D(20X25) are given. 07
Solve the matrix chain multiplication problem using dynamic programming.
OR
Q.3 (a) Enlist the general characteristics of greedy algorithms. 03
(b) Write an algorithm for matrix multiplication using divide and conquer 04
approach. Calculate its complexity.
(c) For the given set of items and knapsack capacity = 5 kg, find the optimal 07
solution for the 0/1 knapsack problem using dynamic programming.
Item Weight Value
I1 2 3
I2 3 4
I3 4 5
I4 5 6
1
(c) Define minimum spanning tree. Explain Prim’s algorithm with suitable 07
example.
OR
Q.4 (a) Explain BFS with suitable example. 03
(b) Define principal of optimality. Explain its use in Dynamic Programming 04
Method.
(c) "A greedy strategy will work for fractional Knapsack problem but not for 07
0/1", is this true or false? Explain with suitable example.
Q.5 (a) Define string matching problem. Define valid shift and invalid shift. 03
(b) Define the followings: 04
i) Articulation point ii) Acyclic Directed Graph iii) Back Edge iv) Tree
(c) Explain P, NP, NP complete and NP-Hard problems. Give examples of each. 07
OR
Q.5 (a) Explain Backtracking Method. Give solutions for 4-queens problem using 03
backtracking method.
(b) Explain in-order, pre-order and post-order traversals of the graph. 04
(c) Write short note on the followings: 07
i) Approximation algorithms
ii) Randomized algorithms
****************