0 ratings0% found this document useful (0 votes) 241 views27 pagesDSA Solved Paper (May - June 2023) PDF
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Pas ~ Jun 2023
aia Write an. algorithm for depth first tra~
é evsal_of graph. — so 2
) = Tritially define a stack with size
same cis total _no-of vertices_in the
gia ph._________--__--__, _
ep2. = “Select the root vertex as starting.
__nocle for traverse. Visit that vertex.
ancl push it in the stack, — s
Shep 3.= Visit an | neavsest Caclacent) vev=
— tex sof the vertex whichis _locetecl
_____att the top of the stack cand which —
Lis nat visited cand push it inthe
J stack es _
_—_—_Slep 4 2 Repeat step 2 unti| there ave no
— any adjacent _vextex_+o_vis) t from.
__ the _vevtex on top 6f the stack,
steps = Wlhen theve Is no any vexte.x_
__-remcein.to_ visit then use the me
thee) of back tracking and pop
one vertex from the stack,
6- Repeat steps 3, 4 and 5 until —
_stack becomes empty. a,
“4_-_When_ stack becomes completely
___empty, then_genexctte_fined_spanni-
4, tree_by —Yemeving unis fool
ezlses fyurn the graph. Hh |
G
- >) Construct +he minimum Spcinning tee :
(msT) fox the given graph. ting _Prim's
algexithm starting From | vevtey~ 6ees)
ats a TERT = ASS yt
—~eilihad ja Appalagical ) Mihat_is_topological sevti 1 Find topslo-.
—— gical cing — pew
ee “sort isan ordering of
——Nertites in a_alixected acy clic: ger
such that if theve js a pla 1
NOt Cj ee Spee otloy
Eid in the caxclesingOr pate ah_ol aie fit _breadth Firs}.
a _, Haversal_ ae ete ve
___slep] = Define Queue of 5} size equal to —
totcl no of vertices in. a_gyciph :
(i Ngre ep2- Select any vextex _as_s-taxti
paint fox +Yaveysal. Visit thet ver-
©X_anel_inseyt+ i+ indo the, Gueue.
——-Slep 3 = Visit_all_ the. neavest _Cacljacent)_
vertices of the vertex which Is
—oat font of the: Queue wWhjch is _
not _visitecl_and_inseyt these ver-
ices, Inthe Queue ere
step 4 - kIhen -thewe js no any unvisited_
———vette1_semaining Pua athe, vertex
et front _of the “Queue then delete
~fcpead. eaereelss ‘ae Eaphy
step 6 - Ishen queue_becamed empty
hen produce fined. Spanning
— tree. _“by_vemoving— unuredl app
—_______elges _ Near the” eaph. aeane
Be byhUs Using - —Prim!s. “algorithm, Find the cost
: of Minimum -spannin tree, (MS8T)_of
- 42 sier— “graph satiny Ner-mst = |tsté+2z+3tlo = 26 a
Oi Deline the. tallaning = E: 7
____) Complete. graph
— B cee graph 2 gaph nic hich
ach wey oxo i connected 4 De
other vertex
=
ph “Connected: gxaph—
Bs eee om isa. Ded gage graph it for |
/ of _vevtices, theve exists
La
Lat | teat om single | cel which joins
— Shem eee sy
‘[Link] _
3D stub: £ nc G_is another.
_ formed oe ateubset_of the. Ney ne ph.—@-3.4) Conshuck. an AVL tree by insevting,
__ numbers From _ 1
> Numbers yy By ly 64-841. &fod CA heise
fact
——, See
=4 Define Red- Black tree. List its ‘pro =
I~ "Gi Fits
| ich tree osith recl_ouncl_ black “edlaw~
| facing racer
be “:
|__P Propentiosa”
_ i) Eveny mocle. is cdlouked either red
1 ov blac
di\ The root is black :
(iS TEE node Is red it'c _chilel-ven.
bey of black ocle
BE ample — c= black node
| _) Se {made
Do-ved 1»
CTs.
(OS
at aa ou
6) Write. fictions for _RR_cncl RL_vota=
tion ithe spect Ap _pwL hee. ——
—_. ea Fe
DRR (Right Ro tation )_ a :
—Tn_ RR Rotation every. “node. moved. —IL SL
se tole Ras Heat
fe Pour,
3% RL ant - lef} xolodion)
RL “yotation is combination of
_single sight ryotetion Fallauedd by ingle.
| ee ~otaton,
ps every made mover one pasit/an
to_aight _Anel_then lef zi
=e.4
cee ae is
[_CxR Qe [Re
Tee ao
| QB L : z _ oO
y
G4 a) Construct — an pV tree toy “Fallauling—
Lata
| So, as, JLo, SP, 3,30 2042 IS,: > (Explain “k- climensianel tree.
a k- ctimentianad tree \(ktd bead i Us.
Ss ace ~Pspetitinden pastitiening —
dade fon iS hucduye. Ty seating
| pai bs fin k= climensi
lip The _k- ca tree. [s_ae y
itp which every ‘lé[Link] is 7
Ke _climensional: BE ES g/t enone ne et) RE
PSB very —non=leaf ngcle can he,
- i Of. sine icity. genexoutin
Ley s) ing. hy petlane_ dee valiuiolts,
_—— es i info. dwo_parts., -Kinown —
asl: ty. Points te the left oF (oh this Ripelane
dives nispemiotedlash uth @ cies bach b =
tree lof that— atle —cund paints to:
e ight of “the ‘hyper lane tore
Q presentec! LPeranirin We bre | ~tree
wera trees ave uselul dota
Sshucture tox severed a plicctions,
suchas searcher jnvdlving “a ru —
BES CEC epee cll mmeene ee eeee
—Ni)aK ~cl_tree ave ct Abecicd case _
FE binary, space pootitioni ing ig tree. =e
= Peeled — stadia and_ olynamic.. tee
[es__with suitetble. example Zz
Static tree table 7
— Tha static Hee table _symbdls__—
ave move jn advanced no insettian
eincl__cleletion ave ettldwedl.
— Huffman tree end OBST “ave &Ka-____»mple 9 stale ree ble. a
cme of Searching a robe L occuring
=jealt jhishe pega: Sena 8
smcu|
e.g: ‘onsT
a ‘Dyndraja tree. fable *
Tn a olynamic. table Sjinbela xe,
inseytec) tet wee then they éome ,
thew axe, deleted when they —cuse
St =avl Free L an examples ot clyng-
mic tree tkuble. ay
as. ‘as Conshuct a acizae Wal male. 12 by.
jtinsextting “oumbexs | froma 1+y_1o
"Steg Fnsert | |
C Oo :
| “Step = nsevt -2
“oe
Step 3 ia Thsent - 3. _ ——
Ct 3 : = i 5
Cover flow) — st
ae tp Tsexd. a| . a
! 31 4,5 S| Os __
| ‘(Ovex Frow) A
1 *
i Step 6-Insexvt - 6
A -
OO @ fey =
_Step 7 ~ Enseyt -7
Cover flow).
HG Tn).
=o @ Ger oS (G3) Or
Coverslow)
=a
ron ae O@ Hath pai bes =
~~ Step 3. a
_Frsert= 2 -
9 la poLs
— | —__tiue i
“Step lo= Lnsert- lo
EK
ee J
ee an) x
CT
LL yo it TE Ts] pO
lao
t= DP Eaplee. y- _jnclex.§ sf aa
clense ln clex
p= .
i _ DS Peimars index.
L Here. ey ‘Fedo piney, igh
[ean ee anlly the p pyimaxy
V yeletion in the table. ‘and ‘primary
I index _{s— gdetine —a_a ard exed —
datafile. ns
— so the date. file ~ je_ovclexed_ ana
this hs = see ieeei) Seconclaty index = it, i a
= Secondary inclex Is. ct Field which
jscanclielette. key, (-@. the, oot oth-
cHhewn- pximerry” Ae oor_—tnan= ar
_clupliccrte, EUW, es
nayse—Ineclex — te
7 Pavel ex —ecorel_ contains. aaa
—_anel_eiclued pointer to the clea shined.
_ago_+the clisk
=So the seaych the secorel_ we fixst
needed _inelex_~vecorel_ to each at the
cactuct) location of +he clota,
_=_Fin_spayse__jnclex_ pene secur
key = el at not creéttioal.
yy. Dense, index - te ?
= On primary k¢ as well, ax_caltumnt,—
— indedin. gis! she ak on whiz
form Fransecttiong
—Que cannot execute — an con primey.
key JJumn 7 oP :
—But creceting jnclex en primary boy
will not sufficient hence ie BL fog te ee allt
__the_seaych__k cdlumns _js_storeel
kisim ethocl. is! -callecl_slense_index,—_
&6 a) Construct _a B& Tree, ae “oveler.
——_ with the ollo. wing cedgs
PH2ZEaAPQEA SW CLA
ca E| step 2 ext.
[a sepa - Inseyt 2%
[i ee
‘step ye Eel kK
7 7 GSD _ O. H kz)
[
ae CK BYPaeteie KLPL
as out Wy
Jn} a ;
aya] p JE) is j
are
}
E] Ixy? J
<[-spit
clA@ 4}
~—fBre? Io Je Tkres_ |S Jt)I rab LN
a Es =
be Jal aret pie) i Np) [sjrJ ta
_— arsed —, re : = ao <
pe Zt H Je NS |
TBI RE
2 — = = ae
—_ H [Dm ai
EE pyr B B a: a —
~ ealian am ib
5) Tie: tree -
it
pipe Bee is a Nery shinight —
sis Lt isa imple trea where the nodes
“them
_th. these, node’ ae, akka-
ligecl fs the, best part of the Trie-
hee
2 Tasextion in Tie dada bru cue, =
A) getithm =
Define a fur? insert (tie Node * é Sook
ishing & word) whit in
—__ rameters on!
Other Foy the dxing.,
1 ~ 7 =
initialize it with the: xeot
_Node and
ino
2%. Ttevate over the \ength of the
Fe i F S
ig_N0LL oY not In the orrey of point -
a | th rent character of the
Sth
& Liy re NULL then, make dn new hed. cand.
point the curxyvent-chayacterx +a thr
~~ new pesbetenpenae ti os
li} Move the cury to the newly. ly sxe
Mo—____| _
- Lae Finally, Tnevement the word Count of
[ _ | the last cur sicent Nede, this tmplies—thed
there _is_a _String_encling—cue vent Node
| Search Operctien=
» Search operciran ip_Ixie i performed
dpa Lnotlay Wau as The Los exti an
poy cotian but the! only olf femence. is
Jo. biat wWhenevce we find thatthe oti.
not
l of_pointers_in_cuty nods. “clae
poi tp the current character of the
He wworcel then acchinin al
ls,
ps as Find) cohetber. the. given word exist
|
xie
\. Find) wh thee any word that ster wi
LK the given _prefi ext fe jn Bie
| @.1eS E plain youltilist files and cova) ing
—>
Multi list files =
= n= multi -list file organization the
fo ~ index _cantain cl) valves -Hna_the
secondaty Key hey in olata file.
“same cs inverted Frle
= But the. cliff evence_is that the —
centsy inthe sm witi_inelex_fone_a_——
secondary key value _ ts_ pointex. to—
nee ded rrecerel with that Feg-
hve Mia oe ee eee
a
SE LER eeTa beer xing. structive is same cy
de cloubly—linked mut). list: chuchixe
Ey p—hi'st fs _s-yuct asa _ciyculor,
_——_pié ~ca_head_nacle.
+ given _circulax L'sh,_ail records
ae ies form another. ci¥-
x Reverse civcular, list contains neole
ik cp .
obit ha What is Segueotial ad laser seo) and index ie
—— fle eganiadtign® State. [ts_advers
Hounal eli'scdvet
—7" vite
Sequential -
Li) “Loa aquential: methad of fF 7
izahien, Yecards a aS
—_anizahi Sea rourTea ena
—_.attvangecl_in_the sequence | ces by which
they “Were. dea ihathe Gd.
ii) Et tk not _passible to insent anew
xecoxe _cuny, where. inthe file,
—___“Tndex_se sequential — a
i) Pn index fora file sis a Ii — 7
Ks ae Values app earing—iia the
“Hild aon _with_ He addy dvees of the
Foote dine aici inthe mass
Las Stnwag 2, orn 7 x
il “index can be. ¢ oxganiz eus_o. lis
Sy The tree, —a_lhosh table, ete.Multiple inclexes 2
each bh pe of field used tox -sembeching
VAus nelexing—provicles_much—_berlter, = §
Flexibility —_____— a -*
i Pn_index file usuctlly 129 wie. lens storys
space than the nain tile. —___—____
iii) Updation of index ti ile cequives fewer _
— block accesses compare 10_Seq Le
file — : ae
"08 9) Explain ivent inuevted and cellular 7
= partition : -
41 : _—_
f Taverted files ‘
| = averted files are, similak to mow =
} __lists. ;
iL = The_inverted files ~ecord informe tian
| _-lis Kept in dhe iinclex itself. —__ s
| > Benefits — }
c i) The ~etrvieval works in two steps,
i) The. wecords are etrieved using the
___tij) Fnverted Files resi} in space saving —
a oogirred to_ other le_stwchine. _
y search aneceneen erR ae isceus OE
Cellular partition -—_
= Fn order. to veduce file seaxch H=—
mes, the storage -meclia —mety_be._clivl=—
‘ decd: into ceils =
: =A cell _mey be an_entive.clislk pack —
$ ot_ it} may simply be a_ cylinder. a
& -— Fn cowed. a cell is aidisk pack henle ing _cellwlay partitions it isp assitle.
to “seaxch—cli ent cells in posal
‘Explain_clivect— access file org, anization.
state its advantages nel cclisacvesnta- an
gen —
i —_——
| = Tn ctivect dddvecciey with equi = ne
———necovels aveuiletble clisk_sp pace. 1 clivi-
chins nodes lage emaugh bo
hold) ol ve carel
=Numevic yelue. of primary Key is used
to_cetexymine— e. node. into which a —
pasticulay cecorel is tp be stored
Advantages =
i) Sorting of the ecords are not
ivecl : :
+ access i el
pmmectiately
Wis T+ har better contra see
allocation
Disadyeunta ja
i) cloes not pravide back wp Facility,
This expensive.