Daa
Daa
T(I)=0
using substitution method
Toe (1) = 8(n tog")
b. Give the pseudocode for finding minimum and maximum element in an array
of ‘n’ number using divide and conquer method. (08 Marks)
Ans.
ALGORITHM Min Max (ig,maxymin)
if (=) then min = max = afi]
j=!) then
if Qi] < aff) then
{ max = af]; min = afi])
else max = afi) ; min = afj]
else
ity
id =—=;
aaa
MaxMin(i,mid,max,min)
MaxMin(mid+1j,maxt mint)
if (max < max!)
then max = max;
if (min> mint)
then min = mint
Swnstar Exam Santoree
00s - Model Question Paper - 1
einey To) =[*T02)*2 wl
Ten) € n)
c. Apply Strasse matrix multiplication to multiply following matrices. Discuss
how this method is better than direct matrix multiplication method. (04 Marks)
CH
ce HC
The components of the matrix C is calculated as:
Gy) = 8, XD, +8). XD, =4x243%x1=843=11
x5+3x6=20418=38
a) X Dy, +g, X By, = 2X24 1x1 = 44125
2) X Diy + yy X Dy =2X541x6= 10+ 6=16
1B j2 +)3 Dy
From the above resultant matrix, we can notice that Strassen’s matrix require 8
multiplication and 4 addition. Where as in traditional way it requires more.
MODULE -3
data. (08 Marks)
2 | 0.15
5, a. Construct a Huffman code for the follo
i, Encode the text ABAC ABAD using generated code
ii. Decode the text whose encoding is 1001011100101
[0.1 015} [02] [02s
B E Lo] c
Cd
0.2 0.25 0.1 0.15
D B
Sanstar Exam Scanner 15[Probably | 04 | 0.1 |
[coterd [1 [roof ot [oo [101]
(Encode Text-1T1 001 101111001100
(i) Decode - 1 00.01 01 11 00 101
BCCADE
b. Arey PRIM's algorithm forthe following graph to final Ce oF
16ee
cBCs * Model Question Paper - 1
sso Ren Vx
ar) (8,3) c(-0)d(, co)
e(a,b), fla,5)
Ans
cS pare heapsort algorithm to sort the following numbers. (04 Marks)
Ans. Stage \(heap construction)
wonnn
anoves
eo co co
Ranaan
5
5
5
5
5
aia rr ©
Sunstar Exam Scanner 17Ans. Using feasibility rule
Ans. Four feasible solutions are
[Solutions T(x, x..x,)
Desig CAR ANDY OF aii
IV Sem (CSE / ISE)
Stage 2 (Maximum addition)
9 6 8 2 5 7
7 6 6 2 59 |
$6 2 2 5
5S 6 7 2\8
76. 5 2
2 6 5/7
6 2 5
5 216
52
2
2
Sorted elements are
2,5,6,7,8,9
OR
6. a. What is the solution generated by the function job scheduling when n 5
15] = [2,2,1,3,3] (06 Marig
[P,)P,, P,, Py Py] = [20,15,10,5,1] and [d,, d,, dy dy d,
Job considered] Action
i assign to [1,2]
Q none
{1,2} [0,1},[1,2] 3 cannot fit
ra a
{1,2,4} | [0,1],[1,2],[2,3] ju 40
The optimal solution is j = {1,2,4} with profit = 40
Assigned job
b. Solve following instance of knapsack problem using greedy algorithm knapsack
(06 Maris)
weight M = 20.
Pr fans] 163] 2425]
2
[sf it.1y | 20 [an]
Solution 4 yields maximum profit item (0,1,1/2) and profit 31.5.
Sunstar Exam Scannera
os: Model Question Paper . 1
te Dijk
Writ nm Dijkstra (G,S)
‘Ass input : A weighted graph G = I,
ACO” she recursive calls end when n is equal t a
sie Condition is A(1) =0. SAuAl 10 1 and there are no additions made then,
he" ly this recipe to our Tecurrence, whi -
s e oe 1) + Lfork>0, ich for n= 2* takes the form
AC <0.
20 substitutions encounter no Problems:
Ney) ACH) +I substitute A(21) = A242) + |
agi) + Ut 1 AQH2) +2 substitute A(2) = AHI) +1
Waes)+ I} 2=AQ43) +3,
“sagt ti
“eat tk
us, we end up with :
A2)=A(1) + k= k, oF, after returning to the original variable n= 2*
and hence k = log, n, A(n) = log, n € Theta(log n),
OR
IMustrate the tracing of quick sort algorithm for the following set of numbers:
4* 55,10, 72,18, 40, 11, 64, 58, 32, 9
(08 Marks)
- 2% 10 72 18 40 11 64 58 32 9
2 10 72 18 40 1 64 58 32 9
2% 10 9 18 40 1 64 58 32 72
2 10 9 18 1 40 64 58 32 72
10 9 18 25 40 64 58 32 72
9 10 WM 18 25
40 32 58 64 72
32 40 S58 64 «(72
b. List out the advantages and disadvantages of divide and conquer methods and
illustrate the topological sorting for the following graph.
(08 Marks)co
Sem (CSE/ISE) Design and Analysts of AL
EX ay) : :
“a:
NEX i all £ 7 delete C2 @ You might also like