Académique Documents
Professionnel Documents
Culture Documents
: ________ 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
*************
2
Seat No.: ________ Enrolment No.___________
Q.1 (a) Why do we use asymptotic notations in the study of algorithms? Briefly 07
describe the commonly used asymptotic notations.
(b) Define MST. Explain Kruskal’s algorithm with example for construction of 07
MST.
Q.2 (a) Explain finite automata for string matching with example. 07
(b) Write a brief note on NP-completeness and the classes-P, NP and NPC. 07
OR
(b) What is the basic idea behind Rabin – Karp algorithm? What is expected running 07
time of this algorithm ? Explain it with example.
Q.3 (a) Explain in brief characteristics of greedy algorithms. Compare Greedy Method 07
with Dynamic Programming Method.
(b) Explain the use of Divide and Conquer Technique for Binary Search 07
Method.What is the complexity of Binary Search Method? Explain it with
example.
OR
Q.3 (a) Explain Breadth First Traversal Method for Graph with algorithm. 07
(b) Explain Depth First Traversal Method for Graph with algorithm. 07
Q.4 (a) What is an amortized analysis? Explain aggregate method of amortized analysis 07
using suitable example.
(b) Discuss Assembly Line Scheduling problem using dynamic programming with 07
example.
OR
Q.4 (a) Write a program/algorithm of Quick Sort Method and analyze it with example. 07
(b) Explain Backtracking Method. What is N-Queens Problem? Give solution of 4 07
Queens Problem using Backtracking Method.
Q.5 (a) Explain Chained Matrix Multiplication with example. 07
(b) Explain Selection Sort Algorithm and give its best case, worst case and average 07
case complexity with example.
OR
Q.5 (a) Discuss matrix multiplication problem using divide and conquer technique. 07
(b) Sort the letters of word “EDUCATION” in alphabetical order using insertion 07
sort.
*************
1
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 Short Questions 14
1 What is an algorithm?
2 What is worst case time complexity ?
3 Define space complexity.
4 Define Big Omega Asymptotic Notation.
5 Define Feasible Solution.
6 What is vector? Which operations are performed on
vector?
7 Define P-type Problem.
8 Write Principal of Optimality.
9 Define Directed Acyclic Graph.
10 List types of algorithms.
11 Write down the Best case, Worst Case and Average case
Complexity for merge sort.
12 Define Minimum Spanning Tree.
13 Write down the Best case, Worst Case and Average case
Complexity for selection sort.
14 Write down the Best case, Worst Case and Average case
Complexity for Heap sort.
Q.2 (a) Explain the difference between Greedy and Dynamic 03
Algorithm.
(b) Apply the bubble sort algorithm for sorting 04
{U,N,I,V,E,R,S}
(c) Analyze Selection sort algorithm in best case and worst 07
case.
OR
(c) Analyze Quick sort algorithm in best case and worst case. 07
1
(b) 04
4
Compute MST using PRIM’s Algorithm.
(c) Given two sequence of characters, X={G,U,J,A,R,A,T}, Y 07
= {J,R,A,T} obtain the longest common subsequence.
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 (a) Define an algorithm. List various criteria used for analyzing an algorithm. 03
(b) What is the smallest value of n such that an algorithm whose running time is 04
100n2 runs faster than an algorithm whose running time is 2n on the same
machine?
(c) What do you mean by asymptotic notation? Describe in brief any three 07
asymptotic notations used for algorithm analysis.
Q.2 (a) What do you mean by Divide & Conquer approach? List advantages and 03
disadvantages of it.
(b) Let f(n) and g(n) be asymptotically nonnegative functions. Using the basic 04
definition of Θ-notation, prove that max(f(n), g(n)) = Θ (f(n) + g(n)).
(c) Solve the following recurrence relation using iteration method. T(n) = 8T(n/2) 07
+ n2. Here T(1) = 1.
OR
(c) Solve the following recurrence relation using substitution method. T(n) = 07
2T(n/2) + n. Here T(1) = 1.
Q.3 (a) Differentiate between greedy method and dynamic programming. 03
(b) Prove that the fractional knapsack problem has the greedy-choice property. 04
(c) Find optimal sequence of multiplication using dynamic programming of 07
following matrices: A1[10x100], A2[100x5], A3[5x50] and A4[50x1]. List
optimal number of multiplication and parenthesization of matrices.
OR
Q.3 (a) Briefly describe greedy choice property and optimal substructure. 03
(b) Suppose that we have a set of activities to schedule among a large number of 04
lecture halls, where any activity can take place in any lecture hall. We wish to
schedule all the activities using as few lecture halls as possible. Give an
efficient greedy algorithm to determine which activity should use which
lecture hall.
(c) Describe longest common subsequence problem. Find longest common 07
subsequence of following two strings X and Y using dynamic programming.
X=abbacdcba, Y=bcdbbcaac.
Q.4 (a) Differentiate between depth first search and breadth first search. 03
(b) Discuss and derive an equation for solving the 0/1 Knapsack problem using 04
dynamic programming method.
(c) List applications of a minimum spanning tree. Find minimum spanning tree 07
using Krushkal’s algorithm of the following graph.
1
OR
Q.4 (a) Define graph. Describe strongly connected graph with example. 03
(b) Given an adjacency-list representation of a directed graph, how long does it 04
take to compute the out-degree of every vertex? How long does it take to
compute the in-degrees?
(c) Define minimum spanning tree. Find minimum spanning tree using Prim’s 07
algorithm of the following graph.
Q.5 (a) Define amortized analysis. Briefly explain its two techniques. 03
(b) Show the comparisons the naive string matcher makes for the pattern P=0001 04
in the text T=000010001010001.
(c) State whether travelling salesman problem is a NP-Complete problem? 07
Justify your answer.
OR
Q.5 (a) Define backtracking. State types of constraints used in backtracking. 03
(b) Working modulo q=11, how many spurious hits does the Rabin-Karp matcher 04
encounter in the text T=3141592653589793 when looking for the pattern
P=26?
(c) Prove that if G is an undirected bipartite graph with an odd number of 07
vertices, then G is nonhamiltonian.
*************
2
Seat No.: ________ Enrolment No.___________
GUJARAT TECHNOLOGICAL UNIVERSITY
BE - SEMESTER–V (NEW) - EXAMINATION – SUMMER 2018
Subject Code:2150703 Date:04/05/2018
Subject Name:Analysis and Design of Algorithms
Time:02:30 PM to 05:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
Q.1 (a) Define Algorithm. Discuss key characteristics of algorithm. 03
(b) Prove or disprove that f(n) = 1 + 2 + 3 + .... + n ∈ Θ(n^2). 04
(c) Which are the basic steps of counting sort? Write counting sort algorithm. 07
Derive its time complexity in worst case.
Q.2 (a) What are the advantages of dynamic programming method over devide-&- 03
conquer method?
(b) Solve following recurrence using recursion tree method: T(n) = 3T(n/3) + 04
n^3.
OR
(c) Discuss best case, average case and worst case time complexity of quick sort. 07
Q.3 (a) Justify with example that shortest path problem satisfies the principle of 03
optimality.
(b) Which are the three basic steps of the development of the dynamic 04
programming algorithm? Mention any two examples of dynamic
programming that we are using in real life.
(c) Solve the following making change problem using dynamic programming 07
method: Amount = Rs. 7 and Denominations: (Rs. 1, Rs. 2 and Rs. 4)
OR
Q.3 (a) Justify with example that longest path problem does not satisfy the principle 03
of optimality.
(b) Discuss general characteristics of greedy method. Mention any two examples 04
of greedy method that we are using in real life.
(c) Solve all pair shortest path problem for the following graph using Floyd's 07
algorithm.
Q.4 (a) What are the disadvantages of greedy method over dynamic programming 03
method?
(b) What is DFS? Explain with example. Show the ordering of vertices produced 04
by Topological-sort for the following graph.
(c) Solve the following Knapsack Problem using greedy method. Number of 07
items = 5, knapsack capacity W = 100, weight vector = {50, 40, 30, 20, 10}
and profit vector = {1, 2, 3, 4, 5}.
OR
Q.4 (a) Write an algorithm for Huffman code. 03
(b) What is an approximation algorithm? Explain performance ratio for 04
approximation algorithm.
(c) Explain use of branch and bound technique for solving assignment problem. 07
Q.5 (a) Write Naive string-matching algorithm. Explain notations used in the 03
algorithm.
Q.5 (a) Which are the three major concepts used to show that a problem is an NP- 03
Complete problem?
(b) Explain breadth first search with example. 04
(c) Find minimum spanning tree for the following undirected weighted graph 07
using Kruskal’s algorithm.
*************
Seat No.: ________ Enrolment No.___________
MARKS
(c) For the following chain of matrices find the order of parenthesization 07
for the optimal chain multiplication (13,5,89,3,34).
Q.4 (a) Explain Tower of Hanoi Problem, Derive its recursion equation and 03
computer it’s time complexity.
(b) Explain finite automata algorithm for string matching. 04
(c) Find out LCS of A={K,A,N,D,L,A,P} and B = {A,N,D,L} 07
OR
Q.4 (a) Explain Principle of Optimality with example. 03
(b) Define BFS. How it is differ from DFS. 04
(c) Solve the following instance of knapsack problem using Backtracking 07
Technique. The Capacity of the Knapsack W = 8 and w = (2,3,4,5) and
value v = (3,5,6,10)
Q.5 (a) Draw the state space tree Diagram for 4 Queen problem. 03
(b) Define P, NP, NP-Hard and NP-Complete Problem. 04
1
(c) Find out the Minimum Spanning Tree using Kruskal Algorithm for 07
given Graph.
OR
Q.5 (a) Explain naïve string matching algorithm with example. 03
(b) Explain DFS algorithm in brief. 04
(c) Find all pair of shortest path using Floyd’s Algorithm for given graph 07
*************