Beruflich Dokumente
Kultur Dokumente
UNIT - I
SECTION A
T(n)= { 2 if n=2
2T(n/2)+n if n=2k for k>1
is T(n) =n logn
30. Describe a θ(n log n) time algorithm that gives a set S of n integers and another integer
x, determine whether or not there exist two elements in S whose sum is exactly x.
31. Show that the solution of recurrence relation using substitution method
a. T(n)=T(Γn/2˥)+1 is O(logn)
b. T(n)=2T(Ɩ n/2˩) +n is O(n logn)
c. T(n)=2T(Ɩ n/2˩+17) +n is O(n logn)
36. How can you modify quick sort for searching an element in an array. Write pseudo code
and give its complexity.
37. What are the minimum and maximum numbers of elements in heap of height h ?
38. Show that an n-element heap has height Ɩlogn˩
39. Show that the worst case running time of MAX-HEAPIFY on a heap of size n is Ω(logn)
40. Starting with the procedure MAX-HEAPIFY, write pseudo code for the procedure MIN-
HEAPIFY (A,i), which performs the corresponding manipulation on a min heap.
41. Show that there are at most Γn/2n+1˥ nodes of height h in any n-element heap.
42. Illustrate the operation of HEAP SORT on the array A=<5,13,2,25,7,17,20,8,4>
43. What is the running time of heap sort on an array A of length n that is already sorted in
increasing order ? What about decreasing order.
44. Show that the worst case running time of heap sort is Ω(n logn)
45. The operation HEAP-DELETE (A,i) deletes the item in node i from heap A. Give
implementation of HEAP-DELETE that runs in O(logn) time for an n-element max-heap.
46. Show that the recurrence
T(n)=max (T(q)+T(n-q-1))+θ(n).
0<=q<=n-1
T(n)=Ω(n2)
47. Show that q2+(n-q-1)2 achieve a maximum over q=1,2,----------,n-1 when q=0 or q=n-1
48. What do you mean by stable set. Explain the concept by taking two sorting algorithm.
49. Given n digit numbers in which each digit can take up to k possible values, Radix_SORT
correctly sorts these numbers in θ(d(n+k)) time.
50. Given n b-bit numbers and any positive integer r<=b, RADIX_SORT correctly sorts these
numbers in θ((b/r)(n+2π)) time.
51. Prove that radix sort will take θ(nlogn) time to sort n elements.
52. Prove that the worst case running time of shell sort, using shell’s increments is θ(√2).
53. The worst case running time of shell sort, using Hibbard’s increments is θ(√3/2).
54. Show that the result of running shell sort on the input 9,8,7,6,5,4,3,2,1.
55. How would you implement merge sort without using recursion?
56. Write application of heao sort.
57. Compare different comparison based sorting algorithms.
UNIT - II
1. Prove that a red black tree with n internal nodes has height at most 2log(n+1).
2. Write pseudo code for RIGHT-ROTATE.
3. Show the red black trees that result after successively inserting the keys
I,N,T,R,O,D,U,C,T,I,O,N,A,L,G,O and deleting the keys A,C,T,I,O,N
4. Consider a red black tree formed by inserting n nodes with RB-INSERT. Argue that if n>1,
the tree has at least one red node.
5. Argue that after executing RB-Delete_Fixup, the root of the tree must be black.
6. Give steps that how to augment a data structure.
7. Write application of B-Tree.
8. If n>=1, then for any n-key B-Tree t of height h and minimum degree t>=2,
h<=logt(N+1)/2.
9. Explain the algorithm B-Tree-SPLIT-CHILD(x,i,y).
10. Show the results of inserting the keys
F,S,Q,K,C,L,H,T,V,W,M,R,N,P,A,B,X,Y,D,Z,E in order into an empty B-Tree with minimum
degree 2. Aldo show the result of deleting keys C<P and V.
11. State and prove properties of binomial trees.
12. Prove that the maximum degree of any node in an n-node binomial tree is logn.
13. Explain Binomial _heap-Union procedure using following two heap and Binomial-heap-
delete procedure by deleting key 48.
Heap[H1] 12
7 15 6
25 20 25 18 10 8
31 30 26 16
35
Heap[H2] 20 3 4
44
37 8 29 10
30 23 22 48 31 17
45 32 24 50
55
14. Why don’t we allow a minimum degree of t=1 in B Tree.
15. Show all legal B-trees of degree 2 that represent {1,2,3,4}
16. Find the amortized cost for extracting the minimum In fibinacci heap.
17. What is the amortized time using aggregate for the decreasing key operation.
18. Show the decreasing key operation for the following fig in given sequence:
18.1 Key 46 decreased to key 15.
18.2 Key 35 decreased to key 5.
Min[H] *
7 18 38
*
24 17 23 21 39 41
26 46 30 52
35
19.Delete key 36 from Fibonacci heap H shown below, where ‘*’ shows marked node
Min [H]
25 8 12 2 1 24
* *
20 25 39 26 46
*
34 27 30
35
*
36
20. Prove that amortized cost of FIB-HEAP-UNION.
21. Prove that for all integers k>=1
k
Fk+2=1+Σ i=0 Fi
22.Prove that the linked-list representation of disjoint sets and the weight-union Heuristics, a
sequence of M MAKE-SET, UNION and FIND-SET operations n of which are MAKE-SET
operations, take O(M+nlogn) time.
23.Write a recursive procedure OS-KEY-RANK(T,K) that takes as input an order statics tree T
and a key K and returns the rank of K in the dynamic set represented by T. Assume all the
keys of T are distinct.
24. Using accounting method find the amortized cost for Enqueue and Dequeue operation in a
queue.
25. Find the amortized cost of 8-bit binary counter using aggregate method.
S
UNIT - III
1. Given a sorted array of distinct integer A[1,………….,n], you want to find out whether
there is an index I for A[i]=i. give a divide and conquer algorithm that runs in time
O(logn).
2. You are given two sorted lists of size m and n. Give an O(logn+logn) time algorithm for
computing the kth smallest element in the union of two lists.
3. Design an algorithm that multiply two n-bit integers, in O(n2) time using divide and
conquer technique. Can we improve the algorithm given by you?
4. Multiply two matrix given below using Strassen’s method.
2 6 9 10 8 10 11
3 2 4 6 9 11 9
10 6 8
21 4 12
6 5 6
A B C D
1 2 2 5 4 5 7
E F G H
1 3 3
1 2 3
4 8 6 6 2 1 4
5 1 1
a. Run Prim’s algorithm, whenever there is a choice of nodes, always use alphabetic
ordering (eg. Start node A) Draw a table showing the intermediate values of the cost
array.
b. Run Kruskal algorithm on the same graph. Show how the disjoint sets data structure
looks at every intermediate stage.
14. Suppose edges X are part of minimum spanning tree of G=(V,E). pich any subset of
nodes S for which X does not cross between S and V-S and let e be the lightest edge
cross this partition. Then prove that X U{e} is part of some MST.
15. Let G=(V,E) be an undirected Graph. Prove that if all its edge weights are distinct, then it
has a unique minimum spanning tree.
16. Show how to find the maximum spanning tree of a graph that is, the spanning tree of
largest total weight.
17. Let T be a MST of graph G. Given a connected sub graph H of G. Show that T∩H is
contained in some MST of H.
18. Suppose Dijkstra’s algorithm is run on the following graph, starting node A. show final
shortest path tree.
1 2 1
A B C D
4 8 6 6 2 1 4
E F G H
5 1 1
19. Find the shortest path using Bellman Ford algorithm from 3 to 1 of the following graph.
a d
2 4 1 2
S C f
-2 -3
3 5 2 1
b e
21
1 2
6 10
5 4 2 -3
6
8
5
3
a.Using Dijkstra Algorithm
b.Using Belman Ford Algorithm
UNIT – IV
2 3 4
2 6
1
1 6
3 4 7 4
8 6 2
3 5
3. Find the Hamilton Circuit in the following graph using back tracking.
A B C D
I J
H
G F E
L
4. Show how to compute transitive closure of a graph using wareshell’s algorithm for all
pair shortest path.
5. Give a dynamic programming solution for the subset sum problem. Analyze the
complexity of the algorithm.
6. Explain Dynamic programming. Apply it on Matrix –Chain multiplication. Analyze the
complexity of the algorithm. Find Matrix Multiplication for following two matrices
3 8 6 9 8 6 3
3 2 9 4 9 4 2
3 6 4 8 10 7 4
2 5 3
A
B E
C D
7 9 8 3
2 6
2 4 6
2 3 4 2
4
8 2 9 1
13. Find solution of TSP defined by the cost Matrix using LCBB algorithm.
∞ 7 3 12 8
3 ∞ 6 14 9
5 8 ∞ 6 18
9 3 5 ∞ 11
18 14 9 8 ∞
14. Find solution of TSP defined by the edge length Matrix X using Dynamic programming
method approach.
0 10 15 20
5 0 9 10
6 13 0 12
8 8 9 0
15. What do you mean by optimality? When can you use Dynamic programming? Find LCS
of X=<E, X, A, M, P, L, E> Y=<A, P, P, L, E> using dynamic programming approach
UNIT – V
1. Describe the generalization of the FFT procedure to the case in which n is a power of 3.
Give a recurrence for the running time, and solve the recurrence.
2. Show how to implement FFT algorithm with the bit reversal permutation occurring at
the end, rather than at the beginning, of the computation, (Hint-consider the inverse of
DFT
3. Construct the string matching automation for the pattern P=aabab and illustrate its
operation on the text string T=aaababaabaababaab
4. Draw a state transition diagram for a string matching automation for pattern
Ababbabbababbababbabb over the alphabets Σ={a,b}
5. 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 n character text T.
6. State and prove overlapping –Suffix lemma.
7. Working modulo q=11, how many spurious hits does the Rabin Karp matcher encounter
in the text T=3141592653589793 when .looking for a pattern P=26
8. Compute the prefix function π for the pattern ababbabbabbababbabb when the
alphabet is Σ={a,b}. Explain also KMP algorithm.
9. Explain Boyer’s Moore string matching algorithm using text T=010010101101 and
pattern P=01011.
10. Prove that Circuit satisfying problem belongs to the class NP.
11. Prove that Satisfiability Boolean formulas in 3-CNF is NP complete.
12. Prove that the Vertex cover problem is NP complete.
13. Prove that the Traveling Salesman problem is NP complete.
14. Explain and give approximation solution to following
a. The Vertex cover problem
b. The Traveling Salesman problem with triangular inequality.
c. The set covering problem