btech-cse-4-sem-design-and-analysis-of-algorithms-105402-2022
btech-cse-4-sem-design-and-analysis-of-algorithms-105402-2022
(In) O(n 2 )
1. Choose the correct answer of the following
(iv} O(n liognl
(any seuenJ : 2><7-14
(a) Any decision trees that sorts n (d) In linear eearch aJgonthm the worst
elements has height ca.e occurs when
(i) O(lgn)
fiJ the item is aomewhere in the
middle of the array
(ii) O(n) flJJ the item ia not in the array at all
.. ·
(iii) O(nlgn) fiiiJ the item i.a the laat element in the
aJTaY
(iv) O(n2 ) flvJ the item i.a the laat elenw:nt in the
arTllY or i.s not there at all
AK23/336 (~ . ~)
f Continued I
https ://www.a k ubihar.com h ttps ://www.akubihar. c om
( 3 , ( 4 )
(e) Given an un.art.ed arT-.y. The aJTa,y haa (g) Jn the divide and conquer process,
thi• property that every element in breaking the p roble m int o s m aller s u b-
array ie at moat le diet.a.nee from it• proble m s is the r esponsibility of
position in sorted array where k i• a {i) divide/break
positiv e integer smaller than •iz.e or
array . Which sorting algo rithm can be (ii) sorting/ divid e
easily modified for sorting thi• array (iii) conquer/ solve
and what 1s the obtainable time
(iv} m erge/combine
complexity?
{h) A p riority que u e is implemented as a
( i) Insertion eort with time complexity Max- h eap . Initially it has 5 e le m ent s .
O(kn) T h e level order trave r sal of the heap is
10, 8 , 5, 3, 2 . Two new e lem ents 'l' and
(ii} Heap llOrt with time complexity 7' are inserted into the h eap in that
O (n logic) order . T he level o r d e r traversal of the
h ea p after the insertion of the elem ents
(iii) Quick eort with time complexity is
O(klo gk)
(i} 10, 8, 7, 5, 3, 2 , 1
(i v) Merge eort with time compleaity (ii} 10, 8, 7 , 2, 3, l, 5
O(kloglc)
{iii) 10, 8, 7, 1, 2, 3, 5
(iu) 10, 8, 7, 3, 2, 1, 5
(/} Approac h or dynamic pt oCi emmina ia (i) If a p roblem can be solved by
similar to com bin ing optim al sol utions to n o n -
oved apping problems, the strategy is
(iJ paning c alled
tuJ haah table {i) dynamic p rogramming
(ii) greedy
(iii} divide and conquer aJww ii' '
(iii) divide and con quer
(iv} greedy a.IFrithm (iv) recursion
(j) The choice of polynomial class has led 3. (a) Explain the working of merge sort
to the development of an extensive algorithm with an example. Give the
theory called complexity calculation of merge sort. 7
(i) computational complexity
(b) What are the rules of manipulate
(ii) time complexity B ig-Oh expression and about the
(iii) problem comple,Oty typical growth rates of algorithms. 7
(iv) decision complexity
4. (a) What is heap sort? What is the effect of
2. (a) Calculate the time complexity of the calling MAX-HEAPIFY(A, i) when the
following problem using divide and element A[i) is larger than its children? 7
conquer strategies : 7
(b} Explain how radix sort works, to what
(i) T(n) = ../nT(= ..In)+ n, n > 2 inputs it can be applied and what is its
asymptotic complexity? 7
=a, n s 2
{ii) T(n) = T(n -1) + 1 / n, n > 1 5. What do you mean by optimal solution in
=1,n=l ' greedy approach? Define the properties and
function of greedy approach. Consider the
(b) Write time function and calculate the graph G = (V, E) given below. Find the
time complexity, space complexity and minimum spanning tree by Prirn's
number of function calls of the following algorithms. 14
pseudocode using substitution method : 7
rec (n) {
if (n s 1)
return(!);
else {
rec (n/2);
for (i = l; i s n; i + +)
prin tI(•algorithm.};
}
https://www.akubihar.com https://www.akubihar.com
( 7 )
Matrix Al A2 A3 A4
Dimensio n S x 11 11x4 4 xl5 15 x23
* **
https ://www.akubihar.com