2
Design & Analysis of Algorithm (TCS-503) CSE-5 th Semester Last Date of Submission: 25-Nov-2014 UNIT_1 1. What are the different properties of Asymptotic Notations? 2. Briefly explain Master’s Theorem with suitable example? 3. Can the master method be applied to the recurrence T(n)=4T(n/2) + n 2 lg n? why or why not? Give an asymptotic upper bound for this recurrence. UNIT_2 1. Prove that a RB-Tree with n internal nodes has height at most 2 lg (n +1). 2. Show the RB-Trees that result after successively inserting the keys 41,38,31,12,19,8 into an initially empty RB-Tree. UNIT_3 1. Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is <5,10,3,12,5,50,6>? 51 2. Give a dynamic programming solution to the 0-1 knapsack problem that runs in O(nW) time, where n is number of items and W is the maximum weight of items that the thief can put in his knapsack? UNIT_4 1. What is the running time of BFS if its input graph is represented by an adjacency matrix and the algorithm is modified to handle this form of input? 2. What are MSTs. Give their applications in computer science? 3. Suppose that the graph G=(V,E) is represented as an adjacency matrix. Give a simple implementation of Prim’s algorithm for this case that runs in O(V 2 ) time. 4. Run the Bellman-Ford Algorithm on the directed graph Fig(following), using vertex z as the source. In each pass, relax edges in the same order as in the figure, and show the d and ∏ values after each pass. Now, change the weight of edge(z,x) to 4 and run the algorithm again, using s as the source. 5. Run Dijkstra’s algorithm on the directed graph (fig. Following), first using vertex s as the source and then using vertex z as the source. Show the d and ∏ values and vertices in set S after each iteration?

Algorithms Question bank

Embed Size (px)

Citation preview

Page 1: Algorithms Question bank

Design & Analysis of Algorithm (TCS-503)CSE-5th Semester

Last Date of Submission: 25-Nov-2014

UNIT_11. What are the different properties of Asymptotic Notations?2. Briefly explain Master’s Theorem with suitable example?3. Can the master method be applied to the recurrence T(n)=4T(n/2) + n2 lg n? why or why

not? Give an asymptotic upper bound for this recurrence.

UNIT_21. Prove that a RB-Tree with n internal nodes has height at most 2 lg (n +1).2. Show the RB-Trees that result after successively inserting the keys 41,38,31,12,19,8 into

an initially empty RB-Tree.UNIT_3

1. Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is <5,10,3,12,5,50,6>? 51

2. Give a dynamic programming solution to the 0-1 knapsack problem that runs in O(nW) time, where n is number of items and W is the maximum weight of items that the thief can put in his knapsack?

UNIT_41. What is the running time of BFS if its input graph is represented by an adjacency matrix

and the algorithm is modified to handle this form of input?2. What are MSTs. Give their applications in computer science?3. Suppose that the graph G=(V,E) is represented as an adjacency matrix. Give a simple

implementation of Prim’s algorithm for this case that runs in O(V2) time.4. Run the Bellman-Ford Algorithm on the directed graph Fig(following), using vertex z as

the source. In each pass, relax edges in the same order as in the figure, and show the d and ∏ values after each pass. Now, change the weight of edge(z,x) to 4 and run the algorithm again, using s as the source.

5. Run Dijkstra’s algorithm on the directed graph (fig. Following), first using vertex s as the source and then using vertex z as the source. Show the d and ∏ values and vertices in set S after each iteration?

Page 2: Algorithms Question bank

6. Run the Floyd-Warshall algorithm on the weighted , directed graph of (fig. Following). Show that matrix D(k) that results for each iteration?

7. State the maximum-flow problem as a linear-programming problem?8. Run the Ford-Fulkerson algorithm on the flow network (fig note dwon from coreman)

and show the residual network after each flow augmentation. Number the vertices in L top to bottom from 1 to 5 and in R top to bottom from 6 to 9. For each iteration, pick the augmenting path that is lexicographically smallest.

UNIT_51. Suppose that all characters in the pattern P are different. Show how to accelerate NAÏVE-

STRING-MATCHER to run in time O(n) on an n-character text T.2. Working modulo q=11, how many spurious hits does the Rabin-Karp matcher encounter

in the text T=3141592653589793 when looking for the pattern P=26.3. Show that if HAM-CYCLE € P, then the problem of listing the vertices of a Hamiltonian

cycle, in order, is polynomial-time complement.4. Prove that circuit-satisfiability problem is NP-complete?5. Prove that APPROX-VERTEX-COVER is a polynomial-time-2 approximation

algorithm?6. Explain set-covering problem with suitable example?7. Write sort notes on the following-a) Divide & Conquer Techniqueb) Dynamic Programmingc) Greedy Approachd) Backtrackinge) Branch & Bounds