Merged
Merged
/Seat No_____________
MARKS
Q.1 (a) Find Omega (Ω) notation of function f(n)=2n2 + n * lg n + 6n 03
(b) Define Big-oh and Theta notations with graph 04
(c) Write and analyze an insertion sort algorithm to sort n items into ascending order. 07
Q.3 (a) What is Principle of Optimality? Explain its use in Dynamic Programming Method 03
(b) Explain Binomial Coefficient algorithm using dynamic programming. 04
(c) Obtain longest common subsequence using dynamic programming. Given A = 07
“acabaca” and B = “bacac”.
OR
Q.3 (a) Explain the steps of greedy strategy for solving a problem 03
(b) Demonstrate Binary Search method to search Key = 14, form the array 04
A=<2,4,7,8,9,10,12,14,18>
(c) What is a minimum spanning tree? Draw the minimum spanning tree correspond 07
to following graph using Prim’s algorithm.
Q.4 (a) Explain Tower of Hanoi Problem, Derive its recursion equation and computer it’s 03
time complexity.
(b) Using greedy algorithm find an optimal schedule for following jobs with n=7 04
profits: (P1, P2, P3, P4, P5, P6, P7) = (3, 5, 18, 20, 6, 1, 38) and deadline (d1, d2,
d3, d4, d5, d6, d7) = (1, 3, 3, 4, 1, 2, 1)
1
(c) Solve the following Knapsack Problem using greedy method. Number of items = 07
5, knapsack capacity W = 100, weight vector = {50, 40, 30, 20, 10} and profit
vector = {1, 2, 3, 4, 5}.
OR
Q.4 (a) What are the disadvantages of greedy method over dynamic programming method? 03
(b) Find an optimal Huffman code for the following set of frequency. A : 50, b: 20, c: 04
15, d: 30
(c) Consider a Knapsack with the maximum weight capacity M is 7, for the objects 07
with value [12,10,20,15] with weights [2,1,3,2] solve using dynamic programming
the maximum value the knapsack can have.
Q.5 (a) Define NP-Complete and NP-Hard problems. 03
(b) Draw the state space tree Diagram for 4 Queens problem. 04
(c) Find all pair of shortest path using Floyd’s Algorithm for following graph. 07
OR
Q.5 (a) Define BFS. How it is differ from DFS. 03
(b) Explain the naive string matching algorithm. 04
(c) Explain spurious hits in Rabin-Karp string matching algorithm with example. 07
Working modulo q=13, how many spurious hits does the Rabin Karp matcher
encounter in the text T = 2359023141526739921 when looking for the pattern P =
31415?
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) What is an algorithm? Explain various properties of an algorithm. 03
(b) Solve the following using Master’s theorem: 04
a. T(n) = 2T(n/4) + 1
b. T(n)=3T(n/4) + nlgn
(c) Write selection sort algorithm and compute running time of algorithm. 07
1
(b) Given coins of denominations 2, 3 and 4 with amount to be pay is 5. Find optimal 04
no. of coins and sequence of coins used to pay given amount using dynamic
method.
(c) Write an algorithm to find out the articulation points of an undirected graph. Find 07
out articulation points for the following graph. Consider vertex 0 as the starting
point.
OR
Q.4 (a) Find out the NCR (5) Using Dynamic Method. 03
3
(b) Write the Kruskal’s Algorithm to find out Minimum Spanning Tree. Apply the 04
same and find MST for the graph given below.
(c) Explain spurious hits in Rabin-Karp string matching algorithm with example. 07
Working modulo q=13, how many spurious hits does the Rabin-Karp matcher
encounter in the text T = 2359023141526739921 when looking for the pattern P
= 26739?
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) Define following terms: (i) Big O Notation, (ii) Big Theta Notation, 03
(iii) Big Omega Notation.
(b) Perform Bucket sort for following sequence: 30, 12, 22, 66, 48, 27, 35, 04
43, 47, 41.
(c) Explain the bubble sort algorithm and derive its best case, worst case, 07
and average case time complexity.
Q.2 (a) Define Algorithms and characteristics of algorithms. 03
(b) What is a recurrence? Solve recurrence equation for T (n) =T (n-1) + 1 04
using substitution method.
(c) Discuss Binary search algorithm, also write and solve its recurrence 07
relation.
OR
(c) Explain Merge Sort algorithm with suitable example. 07
Q.4 (a) Find an optimal Huffman code for the following set of frequency. a : 03
40, b: 20, c: 15, d: 30, e: 10.
(b) Explain depth first traversal using suitable example. 04
(c) Draw the minimum spanning tree correspond to following graph using 07
Prim’s algorithm and find the MST weight:
1
OR
Q.4 (a) Differentiate between Kruskal’s algorithm and Prim’s algorithm for 03
finding MST.
(b) Explain the need of topological Sort with example. 04
(c) Draw the minimum spanning tree correspond to following graph using 07
Kruskal’s algorithm and find weight of MST:
*************
2
Seat No.: ________ Enrolment No.___________
Marks
Q.1 (a) Sort the best case running times of all these algorithms in a non-decreasing 03
order.
LCS, Quick-Sort, Merge-Sort, Counting-Sort, Heap-Sort, Selection-Sort,
Insertion-Sort, Bucket-Sort, Strassen’s Algorithm.
(b) State whether the statements are correct or incorrect with reasons. 04
1. O(f(n)) + O(f(n)) = O (2f(n))
2. If 3n + 5 = O(n2) , then 3n + 5 = o(n2)
(c) Explain asymptotic analysis with all the notations and its mathematical 07
inequalities.
Q.2 (a) What is the use of Loop Invariant? What should be shown to prove that an 03
algorithm is correct?
(b) Apply LCS on sequence <A,B,A,C,B,C> for pattern <A,B,C> 04
(c) Write and explain the recurrence relation of Merge Sort. 07
OR
(c) Perform the analysis of a recurrence relation T(n)= 2𝑇 (𝑛) + 𝜃(𝑛2 ) by 07
2
drawing its recurrence tree.
FIG:1
Graph G(V,E)
1
OR
Q.3 (a) Consider an array of size 2048 elements sorted in non-decreasing order. 03
Show how the Binary Search will perform on this size by analysis of its
recurrence relation. Derive the running time.
(b) Explain the steps of greedy strategy for solving a problem. 04
(c) Apply Prim’s algorithm on the given graph in Q.3 (C) FIG:1 Graph 07
G(V,E) and step by step generate the MST.
Q.4 (a) Given is the S-table after running Chain Matrix Multiplication algorithm. 03
Calculate the parenthesized output based on
PRINT_OPTIMAL_PARENTHESIS algorithm. Assume the matrix are
names from A1, A2, ….,An
4 1
3 1 2
2 1 3 3
1 2 3
(b) Explain states, constraints types of nodes and bounding function used by 04
backtracking and branch and bound methods.
(c) Apply the algorithm to find strongly connected components from the 07
given graph.
OR
Q.4 (a) Consider a Knapsack with maximum weight capacity M is 7, for the three 03
objects with value <3, 4, 5> with weights <2, 3, 4> solve using dynamic
programming the maximum value the knapsack can have.
(b) Explain the Minimax principle and show its working for simple tic-tac-toe game 04
playing.
(c) 07
Given is the DAG, apply the algorithm to perform topological sort and
show the sorted graph.
2
Q.5 (a) When can we say that a problem exhibits the property of Optimal Sub- 03
structure?
(b) Create an example of string P of length 7 such that, the prefix function of KMP 04
string matcher returns π[5] = 3, π[3] = 1 and π[1] = 0
(c) Explain the 3SAT problem and show that it is NP Complete. 07
OR
Q.5 (a) Explain Over-lapping Sub-problem with respect to dynamic 03
programming.
(b) Show that if all the characters of pattern P of size m are different, the naïve string 04
matching algorithm can perform better with modification. Write the modified
algorithm that performs better than O(n.m).
(c) Explain with example, how the Hamiltonian Cycle problem can be used to solve 07
the Travelling Salesman problem.
************
3
Seat No.: ________ Enrolment No.___________
Marks
1
(c) Explain Breath First Traversal Method for Graph with algorithm 07
with example.
OR
Q.5 (a) What is string-matching problem? Define valid shift and invalid 03
shift.
(b) Define P, NP, NP-Hard and NP-Complete Problem 04
(c) Explain Backtracking Method. What is N-Queens Problem? Give 07
solution of 4- Queens Problem using Backtracking Method.
OR
Q.5 (a) Explain “P = NP ?” problem. 03
(b) Explain Minimax principal. 04
(c) What is Finite Automata? Explain use of finite automata for string 07
matching with suitable example.
2
Seat No.: ________ Enrolment No.___________
1
(c) Explain in brief Breadth First Search and Depth First Search Traversal 07
techniques of a Graph with Example.
OR
Q.4 (a) Find an optimal Huffman code for the following set of frequency. A : 50, b: 03
20, c: 15, d: 30
(b) Find Minimum Spanning Tree for the given graph using Kruskal Algo. 04
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) What is an algorithm? Why analysis of algorithm is required? 03
(b) What is asymptotic notation? Find out big-oh notation of the f(n)= 04
3n2+5n+10
(c) Write an algorithm for insertion sort. Analyze insertion sort algorithm 07
for best case and worst case.
Q.2 (a) What is the difference between selection sort and bubble sort? 03
(b) Write iterative and recursive algorithm for finding the factorial of N. 04
Derive the time complexity of both algorithms.
(c) Solve following recurrence relation using iterative method 07
T(n)=2T(n / 2) + n
Q.3 (a) How divide and conquer approach work? 03
(b) Trace the quick sort for data A = {6,5,3,11,10,4,7,9} 04
(c) Explain master theorem and solve the recurrence T(n)=9T(n/3)+n with 07
master method
Fig-1
Q.5 (a) How huffman code is memory efficient compare to fixed length code? 03
(b) Give difference between greedy approach and dynamic programming. 04
(c) Find the Huffman code for each symbol in following text 07
ABCCDEBABFFBACBEBDFAAAABCDEEDCCBFEBFCAE
Q.7 (a) What is finite automata? How it can be used in string matching? 03
(b) Differentiate BFS and DFS 04
(c) Explain Backtracking Method. What is N-Queens Problem? Give 07
solution of 4-Queens Problem using Backtracking Method.
*************