DS Unit III
DS Unit III
S.E.
Struct stock
int arr[MAX]
int top
Noid initiali2e (Struet staks){
S tops
else
s’top +t
VOlse
printfled pushed into stack \n" vlue);
it main ()
steps
the ner is
Return
pointing
Sucess
mpty space
1
cngueue second element
engueur third element
s>
L
Dequeue second elemnent
t
Dequeue thind element
5) o
Dequeue fourth element.
4
empty ueue
write (functions for: CGMJ
) Enqueue inlinear queue
i) Dequeue in ciculor
Cirular queue
i)
inchude <stdioh
tt
define MAx 100
typedef struct
int items CMAX]
int front, rear
Queue
void int cOueue ( Queue*g)
9frontrhj
intis UL(Queuef)
9> ront -)
else
qTeturn vane
Evaiuote the fol10uoing postfix expression witn the
help tostack.
5 3 + G9* 35* +
D
24
24
ab
ab
ab
+* abc
.+*( abc
abcd
+*c
abcd
abcda
obcda!
abc da$L
b 4*| abc d a b
Visuai2ation Visualize a
the staeK as a vertical Queue as
Collectien ColleiOn
Tmple Simpler in stacK MOre Comple* in
menta+i on
Queve than stacK
Define Queue. usat are coditionsfbr CQueue
empty
\Oueue fun' when gueu e is inplenented using Array
Defnation
Queue is a dato-steture in whichdditionof on
elennent is alowed at neend 4renovalof an
elenent ts Qlloue at other end is (aled Cs"Queue
nEpqueue operation
if (si2e) =MAR SIZ)
prìntf("Oueue fUI \n);?
) Dequeue. cperation.
printf("Queue Empt yln"):}
Front (ront 1) /o MA% S12E
Si2e--}
yi9 whot aree applicatien of stack C3M]
Represen4 statk for decima) to binary conversion (s4), to()
’)AOC eII0ng function- cais
2) Memory Manogement
4) Recursiv e funtion cals.
Oisodvontages
) Onee- through traversal
s)MemeTY wastoige
3) can't engueue more elements jf lat poition is Octupie
4) ueu e is full when cear is at ast array posihion,
Even if there are enpty Spaces in the queue
it's ful when the reor is at the lást array poiition
(A
ab
) ab
ab^c
Qb^c
ab^c*d
" inal PostEix Evesrion