[go: up one dir, main page]

0% found this document useful (0 votes)
11 views8 pages

Ds Assignment 3

The document discusses various data structures, including stacks, queues, and linked lists, along with their operations and implementations. It covers basic operations such as push, pop, enqueue, and dequeue, as well as more advanced concepts like priority queues and circular queues. Additionally, it addresses memory allocation techniques and the advantages and disadvantages of different data structures.

Uploaded by

keerthiap2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views8 pages

Ds Assignment 3

The document discusses various data structures, including stacks, queues, and linked lists, along with their operations and implementations. It covers basic operations such as push, pop, enqueue, and dequeue, as well as more advanced concepts like priority queues and circular queues. Additionally, it addresses memory allocation techniques and the advantages and disadvantages of different data structures.

Uploaded by

keerthiap2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

tinclude Ksfelio.

ny
int ahak tMAYJ:
pcqsLau. int top-1;
void pusa Cint value)
piMCEiple. In a dikd tt iptevieuteaton oj sia if (top= NA-)3
AIFO ting pointeS , 10ith eal
uect au dynamically Ciuatcl puuint U' Atouk ovejlool aunct pustedn ;valuc);
in kac aks cae grou0
Ke asual- baled Saus,iitetons, as loug ay
oi Hhet Kixe Siouktopl=vaue ;
availabla.

" eacl NOde toutains: votd popts


dafa (valut) if (op)E
nt uode
A tu<euue to tla
Te ktau uain ainsde.a top sujeveue poining t t psantf( "d poppeol feo &taus", stack itop);
Aatest insected tuo top- -
Stok Opuuatons
" pushtvaut) : inseut a neuo eluuut at tlu
top
eleuaut void diaplayeot
pop) LuAOUe aud uhn he top if Ctop:-)&
uwoving it
peeks : vieo he fop clveut soiout

printsc"Atatk Aluets::
cls podat fov (int i= top; irs0 i)1
int daBa; Pruintfe"a ", shalk L:J);

3
lau sauk
int waiaO
voicl putn int vabu)$ pusl l1o);

neONode. ata : Vaue ;

top: haaNDde; pop);


dia play); *paiwiive opuatiovs
"8nqjusu Add au elmmut to tau o te ayueut

uhurn'o peek| FRont: view ta front eletut oithout reKoving it

o/p 10 pubud to sae


do pulad to Stauk
do puslud o shoik
Stat eluut 30
do 10 4induoe <stdio. hy
int qyuu [S)KEJ;
HO puyud to taCk
Stauk elustuto : 4o 30 10 void euguue tint vale)
eplaia
3. olat io oyutus HOw the quuu io uprejeutcl
oasic ptuitue opeuations 9uus 3 olse
A Qutue s a lineae dat khuctue hat oltous
tu IF0 prinuple . is weea Hhat tle eleueut ingeutd
fisust voll be suuo uEd isust.
St ds Kiuilau do a Rual- ije qyuus uolere the peu, oU Pling'enqyuud :dln", valu);
oho toues fiut d0 Seuved ut.
Quue seupCHOutat on: void dequkte E)
* drray Repus eutaton (hinear qyue) : ifCRront == 4 |l front >sutay)l
" Two pointoes ae wain iaivned:
printg'suiuw io eupty in )3
3 else
front: poivits to iut eleuett panyl deayucud tdw', quue tfon);
JMioY: poitt to last inser kedl elaet fuont++:
3
dsliteo votd peeko $
if Cront - -t l font >uua)
eatle wod ies 2 paut: dafn &
eNt
-fuont last nodes else
puintf front elaueul : tdlu; qualfioud)s
3
void dioplay t)E sa) Opuuations :
if Cfront z-l ll font> 1. ins euti on : Add au oleuuuto to klu prioritg Cuue
voil
a 4peified pauioriky
a. deltton: umou ta chuuut oith Hu biglest priovit
puinl" &u eluuut : )3 fuou hu Quue
3. peek: uhrn tlu eltwet ita
puoving
3
prinyl'u): eg duppose ii daue a prionty quu voith toltouing
eleuuuto :
int waiu() eluaut
A

euajuiu tao);
evyueus t30); 4

pecko L. inseut eleut I oitke priovity 5


" uplo as quue : A(3),6t). ta), Dt).F(S)
Peekus
- Alter utordiug based ou prioriky :E(s), DCH), A
13),
Luhrn 0;
olttut t)
0utpul: eajuiud ; 0 updafe qyuu : D), A(3), c(3,60
3. peek i thrns siu iguest prioriky eltetlo)
enqjud :30 Cisuulau Qutut EpeuatoVs
Guus cauLuto: lo ao 80
A io a dafo stsactre faat kotouos he IFO Prineple
fuont tleuut :(0
aucl Iast eltut io Couwetted to isest elteuk do wake
daqucuud : lo
Gutut eleuerts ao 30 OpeLati on :
enqyucue: add au elteut to Queut if its wot falt
3. lus hean uá opoations peujornual on prioib gul
Üuular qyueue. fuont husn Pauout eluueut o quut
Yeas : suhun uay eleweut
Quiu
Oudeuc based ou tluit
in Quiuw has a
paigrity
pauioriy Bacl. oluct
oih uighor priority Q aucç atel oi Hh it eleuent
AoweL Pori ty. Kuu from elweut w
eleuuut

Fucin eg 1

3
4 rculaL qule : A CirCulan qutue oveLCO Mes te Iiuitotovs,
enque add elueuto A,B, o} a Aiuple quiuu by counetking thu eud ef Quue atk.
updatid Que. : A, B, C, -, to front tovuing a crcde.
que add eltueut D,E Cpuatows: CuquutAequue
lpdatue suL: A,6, C, D, E utlizatow
Advautages: flueut vaucy
diauiue -suoue eltuut A
pdatd çuue : B., D, E, - 40 SD 30
euayutue add eleLt F
F
pdalrd gut : B. C, D,E,
fuont-uhurns elut B RLEOY

suaT rehus elueut F " priovity Que : Jt 2o a kpeial type calare eacl. chuuut
Adya Aas a fricrity aud eluuts volti kiger prioviH o
dagjued buore teoer paiovity etc.
THpes AsLeuclug priozity Sue
dis advautege prioriy Queue
opsuatous : enodto.
puiori ty adlvautoge : eusuree tou oith dugler priorithy deletiou
as suvedfsst ex: elLut
piovity
din asl vautaqe: oupun insertions Cula Soxhng LO

H. hiot aud enplatu dhe 3 hypes o Quw Hhat elns


Qyue io neau oata shustaue
Luuowd 30 lhiglest prioviy:
oß te appliuaton oh Que
Siwple guut: is he wost baXic type o Cuu olant 5. wiot Boue fo
iys etion appeus at uiak euc daletion oteuus at
fout eud. oY jo6s Hat wetdo be eneuttc in a
Pauki ulas Oscir.
Opatious: euauu, daque
psunA Que: psit Guuu aue wsed o wauage pint
SpaLe at font wLo eliiuts tauuot be addec bnca pbs in priukoe, eleLL douuuus aes pviukel in a
auL BLeceised.
ravsiH Cq: int p- in ) allou (s, Siao| Ciut));
Hhat nud to be
uauage datt pakels
a o euabe block
Quue: ted tn dishibuad ys aus to you Loaut o insn eale or dtuCare wiCTY
Cununi taton basenve di }feuuee taupoueui.
Bauadkh - fisest ktastle algorithm : te tuoese gapls or kyntua: ptr (hype )sualloc (ptr, reo-Sine);
data ou cliok aus
eg: aus (in) Lolls c(av)t0t Site of Gnt)3
" iSk Btlusdut na : uanusto to aues
Aausllio using' Quueu ensuu dah co
suad uri ten
Bynta: fst (ptr); ualeases tlu mamory atotakecl bar
6. seline win kGa liot eleuta 8. kiot Alu di4fouue betuseuse Shatic Gdynawic ymory
A kiukes Liot is a lineau ds u wiel alloation
lallsd nodto aru ounteod uing poiur eacle uode
Shatit
dynawic
" Sata : Shoyes tlu Value eLoYy io aloatol at o allo cotuol at
Coupite -time
Poiuterisore te adasus of Mext uode in iot
ewuuts u St aas a fixed e
Uke aways, i e tiot don't &hore irsetan 6
Conhqucus wwory Loations, eich wakes
dal~on opuuatiohs wore elflueut. wuavagud by oupilir
4.vokat o dynauic wumory allocotion ? iot § nplaiu "alower dub to allocatzo v
tuncton o dynaui GwuMoy aio totion.
PMA a"puoce of at~eotuq to vayables wd i Bin kol liüt ndunami
auays. tues ete
allocatia

fuuetions Wied for DMA dout aufunti caliy by systam wust be fuaud uanaliy
- LeksWs a poiukr to beginning 6 Btock. Wses watlote), (ooc))
Auallec) dor ollocation
syniun ph : (ype) wlat o c(sie); "eg: int ass lint) alloc
eg: ina p: (in) alloc (s Sio Cu)3

blou bucs enghaty dallo catiel


8ynian: *phr = (hpe) colioc In,sia);
errot Aotating wwoYy or a nodi:
SInple to ue & l t poiuar Luuelng e Wid o alo Late
plione
Cauuot eiue dlu kawe
Quallo
WLwory spae for difereut
int data

hatkes. globat lolat vaviab a


Adinutage: at ates kdvaukage faitle kie Aeps : t. B:ne Ahruchure gor uoct wsing shruct
0 ueory daks iueut vuy utuage 8. we mallst to alLOca wuory for onode
3. chue i way dllo cotio) was dutteu ju
"Qisadvautaqe: kas faqe ot wwy- lsachvauagesloceu auey
mawual wtQLageueut. S. suusn muuoly sucus wode

alloatt tu uwMOry
9. dow cau nu uoh a uode
builallug 6lock
CLatt ug a Noda : uod io a basic Qua.
Cisucullay Qutus. io au advauced! euion of a liras
a ds
data ioyed in oce ueB thct olu tL iuitaton uuused poue in
-8ata : luo io acual
NescE Zhis so a poiuty that
poiut to wext mode in He aneae quue
Advautaqes
#induds (kdio- h
tlindud <Btdlib.hy - jn tineas ayuue ,OLe puase duacler euc, no wove
elweuts tau be inseutcl ewe i8 tusce ie spale at front.
int data an urculau ayuue, Tece cau oTap eound to foont %
Anut Noda N qrute &use eupty spaue ,]Maproving cpate utlization
a. Bette Se of Space
int waiu)
shut nNoda"aocdel - (Ahutt wode)uallou euen i teee is space at frout
up de 1- UNt NuiL
tuphy pae at front
3. Avoi ds lse 6uey ouo
Punt L'ata 1.dln ", uncdel dat)
Htuse ' Apace
duacl- hwNode;

ime Cou), wid tteup nt! NUL)

elueut
6. NO MICcd to slilt don' t baue to wwoTe ele
n touclau Qulue, ha
Aaves tue oid daleh fromrout ()
a<o dultion, okicd
1. 1oik apogunu to luphaut ypiooing opuat on prunC' kiot cuptyin ;
uchuin;

dalétng a eliuut at que positon


void dulotefrom Reur (5
thnuucle stelio.hy iPthead ::NoLL)
#inclucla <Stdlib. hy
Shutt Node i
int dataj 3

fousthead);
Ssuct Nod luad =NULL;
voià insot At Bagcning Cint valu) &
AAut Nod1 vlo Node (shue Aoda ) uatoc Csiuok
(AhucaNode); lile (tewp+ want wwt}NO)
Aeup- tespnts
fuee ttuupnt;
void insButAt Reae int valuu)
Auct Nodt weLoNode :(swut Nodo +) wuglla (Aiao} (Sh Void dulztAA Posihion lint posihon)E
Noc ); if Cheacl-= NUtL1l posi ion (=0)
uoN Dele data =vala ;
paingnvaiel posi hon or euugty Liot \n);
if (posihon )
dukteFronfrontC);

fovC int i: t;i< posi Hon -1 44 tump VUnt! eNOL ; itH) $ hist 0 inseutions : ao + lo -+ 30 -’HO NOL
dwp teup-znd: AfRY iletng trom gront: 10 3o -tko NuL
if (tenp- Nd NUL)
paintcpsihon eut of Yaugeln
DALhuYn;

Srutt Noda dinole, =teup nxtj

fracdut Noda);
3
veid diaplayto3
Shut i od teup =had;
slal: (teup! =NuL)t

int waul)

ins oÉAHBginningt10)3
insuFAHReaA (80)

diglayoý
dlite_fromfrontt);
ringc jer diltisg bom suay :
di play())
duuteAt Po5ihonla);

diaplayony

You might also like