DSA Assignment
DSA Assignment
n*eeftor
nnoa
fre3 Strususe
ab
npa
sfoueli Nor
Linoa a l a Stsuolure
ae
alomeuto
Sala
a30a a u g hierarokial
ala elem@nlo alta oheod in
n a
neod 0reroker e man noS.
elemonli is 02
in a singe oun on
un oDnl
MomaTy io uizeo
uiized
uliized in
MmoH i nol
fn an ofieient co0ay
Crefine ADT9
An ADT io a mavkomalical model of a dala
stouelu se that sbecifieo the ioe of data slored,
Dhe epealiors suppoal On Rem, and tHe pes ef
aa mefrorg tle opezaiomo. An ADT speafieo t
a opealion doea, bud ut hots it dloes it. kn ADT
Can be inplemestood uoing one emay difforst dal
Stououses.
6) MenDon the Beopbes ie o ADT?
7@ Conalruelozs : ereale an inlarce that baskeuaa, olala
Ace eas Puneliona: Funeliowo cokie ot us t access
elemeuts of Ke oba pe. Enampla bke J81N).
Manipualion beocecdure: It sorulo lotus manipulate
0 modi he dah h e . Exanph bhke Insezt. Welele
Head
W h e n slng lnkeel s t
eam be vepaeseted a
eaa
ocparesoted
be.ebresonted
list
Then
Then Re sad Lsnkeol and oe ean calleodi
liot
linkea
eir nlar
keod l s t
S/g eiroulaar
3 When doubla linked lt asn be
be vepresentedns
oircular kes ott Ta:l
Head
dala next brov lalahe
bv elala ext
(G
.Teaversinai mora me
e0nsu mia ad oovezyse
tra veash o nst bossible in sina linkod lista.
Dests.
6) What ove
advantoges Qd dio@van lag@o aaara
implemenlalion aover lenkea iot 2
Linked iat
Acd van Tapes Ravdom Hee@xd Fast Fat Is0 Lon/elolion
Seasek Tim@) te
Less m@m00n ecle n a n i a size
per elenOn EPiciet memoy
Bettar cabhe Loali alloenlion/ili zalio
isadvantagesSloco inceslior/eletion Slbw searek lime
im. Mora memoy neecde d
Fixoo Sze pe ode ao addito nal
In@fiai ent mem0ay Sloarage aequaeo or
alloealion/uli lizatio oteas.
)What io a oiaeular rkeo Diet2
T h e link Prela a He last o e eonlains tke m@moay
The
addre aHe fhst nosk,
Sueh a laked lot iw ealles
eireula lenkea bot
and quoue.
Inple menlalion of saok quoue.
HLGORITHM:
PUSH (STACK, TOP, SI ZE, ITEM
knkes l t
4) Hoco he operaliona peform on
hm-plemenlalon o staek ?
7 3faek Czeahon_uabo Lked lif
void ereate (staek **p)
t a p - NULL; /top ponto to ANULL heaZio
n p staok »/
3
an olein t tb the staok by iushha ked
void h staok*p, ht elemat)
staene;
OLS-staol") mallee (dkest(stacA)) ;
ithes= =NULL)
potfA \h Staok io full),
Oit)D;
3
hesvalue = elemsnt
ne9next =*ap
tep nes
3
_ (
C . C
( |1
ET O
C
25) What ade he apklicalio o stack 9
iset abb lioations
Pape- vlsi d hisloan in a Web baosea
lndo seque nee atext ed Toa
Maokine
Chah aaf mehod callo in the Java Viataal Mathine
Vali due amL
Tnaioeet appi ealiona
Aurlaoy data structnve for algoait hm
Compo net o oker data staudnde
26) w e Phe algoith m to pop a eleme Prom a
staok 9
ALGORI THM:
POP(TACK, TOP, ITEM)
io the a J r a n coh
N elem Onts, TOP i H
STACK
poter H e p othe ekmet o t e asa
ITEM be nsetod.
msert
at both o , One end io alsay4d woed
asm0e daia
daaoueue ad oer io usoa
dlea ueue
2) What ade he operalkon a queue
voidd noueue (ueue *q, telemet
n he queue */
* Insestf an elomet
int deauoueausue ) Romove an ekmeut foom
he 9ueue
gueue *erenle)) Create a nezo queue */
h ombgeue *q); / eheok i queue ls mpi
t dize (queu@ *a);
/Rotam te no. of elomeT
ueue
13
1FRONT =NULL tHenCeek hoat onl on
FRONT -1
REAR
eloe
ReAR REAR +1 |Inczement REAR
Rotuan
END OF IA
EXIT
(5
36) At 12nguisk betcoeen stack and 9ueue
S tack Duue
Elemento aze hseat Elemonth ore insealecd os
ad demovea af e same 7Omovedfrom dijjerat ed
dJferet
are wsed
Here, just On bote io Ts0"polntea
wwed.Ibohto He tob t poht frot ad ende
o h e staak.
Staok follocsa Last In fast ueues folloeso fist In
Ot (LIFo) coaer flat Out (FIFO 0rder
Staeks are visua.lireo as ueues, abe visualizeda
verZical eolleelios. hoaizonZal celle elioe.
Man operaliosot staak Man aperalions o queue
Dre puok and pbop. a7e OnqueuO and deaueue.
A A
A
AB
t
ABt
ABt
ABt
AB+C
(19
+ + D
D D
&,
2
O+ + D
Co
++1I+ +
c
(O
u
2
+
D
2
p e elor Staak
Curreut Swbol Poei Prp
AB
+ AB
A Be
+
ABD
D + AB-0 D
+/ AB-CD
+/C AB-D
P /C AB-eDP
/C AB-CDDP
+/C A8-eDPR
+/ AB eD -PR
+/ AB -CD-PR
an Smp zod.
be placed on top smaller han it
No disk ean
he definio
of
Faom
A a@eurslve funelion, a9e
A8 olion
that i f afun
kno o
aokele
To perfoTm the
A opeaalto he Funolion
A
2) Give he applicalio of prior i queue
9uoue2
t o s t both algoa
h o afost
Tt i uoed TRe C:kstbo'a sshn
Tt io woe n brhn's algoaithm.
GTt woeo heap s0t Soat.
Hutman eoVo