Professional Documents
Culture Documents
B.Tech DEC 2022 COM CSPC-21 SEM 3
B.Tech DEC 2022 COM CSPC-21 SEM 3
B.Tech DEC 2022 COM CSPC-21 SEM 3
Algo (there is no
need to write the code): q'^4
PART B (ATTEMPT SEPARA'I FILY w,ithout mixins with I,Alt't A1
\OTE: Attempt QS if 1,ou want to scorefull 20 marks. ln case-|tou clun,t know,the unsw,ets <t/ eS,
you con ottempt Q6, but then you will be able lo score mox 13 marks, not 20. Don't attemp bollt.
5. (a) Consider the following B-Tree of degree t=2. Shor1,. B 'free after insertion of following values
one by one: 8, 30. 100, 75,25.
ffif
rg:n1 ru 4z 1t 7s
(b) Assr-rme that all edges of a directed graph are stored as an array o1'structures having
{star1*v.
end-v, weight). Write a function in C with proper parameters to generate nvo arra),s trom ihc
given input array: (i) array of all loop-edges i.e. which are pointing to itself (ii) find thc verlcr
having highest weighted outgoing edge & generate an array clf edges oLrtgoing fitnr rhis vcrre\. i
(c) Assume that the activity selection problern is to be solved using Dynamic Programming.
(i) Write its recursive solution using optimal substructure (write mathematically / C-f unction)
(ii) write a function in C for its bottom up DP solution. You can use global variables.
s
(d) Consider the following code for the graph-coloring backtracking-problem using m colors.
Write the pseudo-code/function in C for nextvalue(..) function. s
void mColoring(int k)
{do
i iiextr.aluc(k) ; if (! :{[l<] ) break;
if ( k =: n) printresult0;
else mColoring(k+l); )
OR
(a) Assume that the input graph is directed and is stored using adjacency list. Write a function in C
which generates the equivalent adjacency matrix for the given ad.iacency-list based graph.
compute its time complexity and give two lirre explanation lor the same. 3
(b) Consider the fbllowing B-Tree ol'degree F3. Slror.v B 'l"rcc alicr inscrtiurr ol' lilllorr irru virlttcs
*!
one by one: C, Y, K, E, F J
(c) Write a function in C or pseudo-code to find solution of N-Queen p.oLlem. Use of 2-d alay
is not permitted. You can use l-d array. 3
(d) Prove the followirrg Theorem of LCS problem of Dynamic programming: 4
Let X : (x 1,x2,...Xn,) and Y : (y,, y2, y3,.... yr) be sequences, and let Z : (zr, 22,...2p) be
any LCS of X and Y.
1. If xr: y,,, then Zk: Xrr: yn. and Z1_1 is an LCS of Xn,-1 and y,,_1.
2. If x,, !: y,, then z1 !: x,n implies tl-tat l, is an LCS ol'X,,,_s and y.
3. If xn, !: yn, then zp !: y,, implies lhat Z is an I_CS ot'X and y,,-1.