SUEUE
in t out puncple
QuueusoNks e n t
Dplenuhen ueue
Stackimpleuauta.blon t h Huay memmou4u Hquid or
ipltmeakahin
legxiten Opnahis pAnLotmd
OAsuat Linta Qurue )D
L uinnas uue
Abd18 () / Erquue o
ATMa alue be inekd g : ADL (A, 12))
A auoha callina ADDLS CA 3)
Aca ARa t 1
ALMaA2 nut value
ACA1 13
wheneu ADDLQ0 will b_ Lallud bnly scaa wl int
nt wlt manO.
Algosuthm te ald clucuws in qu ADDLB(A, valune)
O Chack te
O ar 1 )
Aant 1
actua inauh'an
A Laca valuue
m quu DELLBO1 deque ue )
Ptaho
AI t JAo 1
mtJuent t4
sAent uas 1
Algouith te dalek elamenks
O Clatck undatw ndihon
i f e n t =1)
Mitn1 )
9 ent Ce
hetk i Laat elems e
s hung daleed)
es
Uet t 1
unu
ace2|O2
AIxuplenuat a queuexA h halp twe STACKS
wet data ktuualuea pueunkdbu leung code.
Veid xz
PUSH (31, F
tack gp,ep($2
i (slck euuph (sO)
psuint(HE)
else
1 uhile ahckmphy (st)
xpepp s
2 PoP (S2)
Guee
Aike a
CIRCULAK QUEUE
i eait 1) MAX 4ent
leucendie
hdnlou Londihon Luent - 1 .
ALaN uutl aAo b-1
Doube ndid QuuR E a kind o queua in
uwuchlmeuta be adddand EMAAed uem
both eda auk net fuem middle Th kna
Dequue i kkn um doubl-Quducdquue
eR a 2 yees eoaqueue
pLtutuickd doqu
pi)Oukeut uoatauckeo dequue
nput unticd duauuu Hiu quue alleuu
insube mlyat e ndau alleus dalebiesa
Output tuekd HaL quue alleuuu ulunn a
bet edu buE diletern t y at
e nd
fuchems e Dquoue
t nwhe at
lwuhion at d
(TDDlehio at Juont 20o
Dtuhen a ud
auplexueatatim D0queue
nAebm at uan o
void hen-at xa int 6LI int val
i eA MAX-1)
pint Dequu Jull at end
else
i i La -1)
3 as 0
tentO
else
8sai ualue
D uien at 4soat Cd
vod insuhenat faentint QLL, int va
ii 4sent 0)
punt Dqueue ull attLeut
elu
i_Lfsmat -1)
Jeos MAX I
f t MAx-L ivshm
els
sent fLent -1
LArmt val
AkRy ot DDelehimat ev
sPe int odelale xevnfesn (int L1
i nint
pxink ( DiquALp haphy at fuut
kun -1
QL4Ant 1
hek Ata) 23
funt-1 dulukd
Aea 1
elu
olelek uem ua
int del from a tn a
int
i Rta -1)
paind Diquu iR ph )
y ual
i ua fion datete
ta Uea
kun ly
Applisahgm eauue
CPU 2theduling
D QuLues oKe aAe useul hime2hau mulh
Opliabing Akm u MAany AL ha CPU
Aiulkancouul
i)Quue Ja alee utdmchaiud 110
nainniuk duuer a kd e
amqL quut pintf
fg pMnt quu
qu
en a nRkuekpuink uiauth quus
uppintbb u d
Dae 12
Pag
ouiatih OuueA puosuhy quuo a q u uliek.
earh eltmn akAigmud 4 iDALy and d DsdeA
in uwh tlmALsks u oekkal3 pLecesd
Bes applitabm o uiauihy que obemud in
CPU Ahtdulk Job u-huch hashgu puosdh as
4 4hpio o 2 jobs k 2am
Hun taue axpkoced oCcordipa to Hreu
paluhans in quRue(EI£o)
A ghet ob s qiun a higais puto-uky oAJangeu mL
Kuptcnbahb puisuh u e n (puku an
ti Ain a intas inkd liat
i Una a ukiple uuiHepesemahn
allo O allecau wwouy n hiap ks
Linked Qik Aalakem a AAQ daa Rgoplanenke
SoA daa e
NuLL
Lxt ode
add ium
nodus
head paikka Hat avkau addun e 1 oda can
arcuseo e Stck0LO
l i s tLowAa
inkod
nkcd t
a incan inead
elowmuk
Lheu o moqeutouA dala
LAllud nedi A nodltensiu t 2yee
CR inomahon ield holds ta
atkal nauhon in a isE elomnk
1 nxt addis t e t d helds addliss
nexh ode in he Jie
he next add i s Ld ta accis t nust
nedes kneun aa posnA
The cni ina linkdit is ed ko ond
aecesed byApainkh usich pains o H ut
l i tlit cellad head neda
od o{ H JAs Sspecied b
Ahuing nex
pectal mbal kusn a ul paink
i addsss ld
e dinkd Aic
dincor linkRed
Cuculos unked us
Doubly inkdls
etkakon d iwkad Aick
Dynacplanuaha
Tushon a nodi ak aE
Wode O
Date
Hypd Auuc Lis INFo NEXT
vetd u u
bea
K NEXT NO bE
NOBE head w al
S NoDE KptA
ptA Matlac ai22nNoBE)) MGXT
Fiela NPO
'nihatuzah pta INfO M a l
NULL
Pt NEXT NULL
i htad NULL bu
&hLad pta
pto NEXT k head
head pta
2suhen abe
inuhimbeq NODE k had tu val)
NODE k kpt
pt NoDE ) waltec (si2zap NODE
pe AAadiv
p age (AfO val
ptx NEXT=NULL
k head NUL
head ph
pha NEXTA head
k head pta
NODE H
H NULL
Tnst n beq (H 1A)
rim bea (H35
Paee
Tnuhon atDat
Alpoatihm
Decla eainkeut p t Loc
Aup
Skp 2 Meuno aLlecahen
pt Ca ae nd
p 3 Fidd inthulzn bieu vt naadle
PA INFO Value
pt NEXT NULu
p Link abeue neuy cuakd odo UHa unkd Jit
Ap t u npty tatn
head nuycuaaLEA ncle
Loc head
while (ocNEXT=NULL
Loc loc NEXT
p LoU nk ed nade Lpha)uit Loc at end
loe NEXT Pt
Akp End
Tapleuawttan Hen
VoÍd iaukatlaut NOAE had nt vattu
NOE pt2 oc
pts (NLODE )aaiLocSize
pi INFO value
p(NODE)
pta NEXT NULL
hEad NULL
hood pta
3lec head
wwle Loc NEXT
1 ec NULL
Loc NEXT
Aoc NEXT i3
Maun )
NoDE Aheadd
h ead NULL
ttttttrtart instulatkast &head ;
wut at Last (&had 20)
Mietat ast (3hsad 13);
vold dikplau (NONE head)
aile (hsad NULL)
paintt d"head 1NEo)
head= hsad NLEXT
Tuhion e a giu_vade
void inuHn aR (MODE had int valu int alR)
NOEkptakloc
p t u mallec (sizto (NODE)L
ptu IfO vatu
ptu NEXT NUL_
Lo head
usile ( Loc NMfo ajk & 2 loc NULL)
J koc NCXT
p\A NEXT loc NEXL-
linkd liet
Plek ut node Juena
int delLiutLNo DE t* head
iny
LDDEkpta
pte head
raitYRhiak
head NULL)
paint tistis cmphy)
tChusn - 1 )
else 1 R h e a d ) /NFO
pt k head
*head = (head) NEXT
Apptitokievs o nkad ixt
MuLkipluicahen
Adduem
i Rupenkalin Pouuoial n Lewpute4 ew.osu
2
6- 3 2
lo 3
-S
L
At B
c lo to
1-S- G peuse ax
ige pema Laed tist Saune uukceqp
Auim
Taihatize p& 4painks kpelyinonual uked
Alep 1
aist A 2 6 Lpecbiluyp -4
KRp 2 ALocat
C2Caacle a n ds
&hp Kptab nex kph eitu 46
wtuile p2 NULL and q NULL
&kp Cevmput Hu pttttieA pemenk raxt i.
i p ExP q xe)
2 cOEF t q coEE
i ( 0 h n atasHhi nadL
uu ceiciust and expevcatpep)
uih nkedJuE C
ATTA CH ( P P d
aduanee petnR nex
P NEXT
NEXT pekihen
h n attacta nA d w Coa coEf
4 EXe h liwked litt C
and
ATTACH ( Coef 4 Ex P, d)
2 q NEXT
Aup 6 L x Ex)
hn aHae wede wi h Ca p2 co6f ard exp
c
p ExP uuh id s t
ATTACH p co GF p CxP d)
p p NEXT
Sh
p py teaink ms paluenuta
stl (e NUL
AeLHP Go f d
PpNEXT
palonual
eus o
PMnaini
ule (q NULLL
ATTACH Co-45xf,d
9 4 NEXT
Siep 1 d EXT NUL
2
C C NEXT
Sohing AangunuLuk edaa elemciadd in ascndig
deLcunduA 0uda
ypLAD opoo.ches 20hi
O Titsia ase Exkunal Soxhn-
Sabl u Uaabl
Q Tn cepltxiky
vsApace
Rcuusiw vls anLLAiLLonuplex.iry
Tiw tmupkxih O no Cenpa aenA
xhng kahhiqwA
i. Buedl 30
1Coleten 0k
w.Quick Sou
VMIQe oxt
vHenpSot
ViL Radiy 40ut
# Bubble Sout
i Ti Coplexi
Toal No,
dcepauAt e CEVApaxitens i Lfas 1 Pam2 tfakb
tPas (-1)
N-1) + (N-2) + +32t
N-12 x(N-) CN-1-1)D
CN-DNN
Tiwe coplexiy O(N) but cas kst cae
aueage case
NaId
NAId
bubble Sosutint AC1in n)
iut k4ppa na,
0 paano pasno<njpakkno++)
hpassAO
jou ie0i<aitt)
Afi2 ALiI
ienp AiT
ALil Ati11
A ALill= mp
Selachn Sgt E unaael alaoxiHane Bauc idta od
ALlachim o i aat
ti find H Amallea lonent in quen is and put i n
4S pokikom
fnd 24Smatleat emuuf in9nAaini rstE dnd pu iE
in 2 pokihe and 30 a
9TupBomaulahien oAliobon gsut
t
votd elockien sou in ALL
nt N)
int n lep k oc
b KO KNK
i mia E win ATXI eck
A i-ktl i<N itt)
i win> ALi1D
Joc
tewp A LK
AR Aloc
ALto c emp
Twe Lemplexih
Time cuplex A no eMApasu&eu
n Lempastis.euz N- N 2 N-3 3,2,
NN)
o(N is h eMplexi o
sAt a
a