0% found this document useful (0 votes)
4 views

queue

Data structure

Uploaded by

farahmahmoud266
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)
4 views

queue

Data structure

Uploaded by

farahmahmoud266
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/ 4

Frrst îe frst out

Queue Head |Frunt

Delueue
BacklTail /Rear
"EAueue PusbAds elemen t to the bacl the ueue.
"Detueue PoP:Remaves element fromue.
"Peek orFront: Shows the element at the fent wlo deletinit.
rear: Shas the element at the rear end

" iSEmPti chece tit'sem


iSFuli checkisFull
Using arrasA
#incude< iostream>
uSing namestace Stds

defioe 512e 5
intShee [sze3;
int fron ts-1, rare -13

Void Efee Cint Nalue) miyan


W Lw hwa m4
, CrearSze -1) vif it's enPry
reart+ ifcfront =s-188 rears s-1)

Aueue Lresx Is Values ?


eLwKan tehareon
)
4 ueueL++rear 1 Va weg

eise Ceut ce'IT'S Full


Emity Coutc<" else
Coutcend
«s? LrJ 9ueue :Caut
<<
i++)i<=rears taront Cint For
<srear) trant rear-1
Re(root,-182
8&
DisPlayC)i VÛd
-3 retum c^emPt cout else
otli Era MeneT return
rear)frontxs b-182 rear 88=-1 (Front if
PeekOl int
emty3 cc"ueueis Cout lse? e
t+Frant
<=rear) fronty=-122 rear -128 ,=tront it(
(tiDeieue Vord
using inRed ist
Struct Node
int data
Node * Nexts?

Class ueue
Puollc
Node *FrontB
Node * rear

Queue() front =rears NuLLsN


bool isentyO be front =Nu) retum Truej
el se return faIse

Vod Enueue Ciot item)


newnude da ta s?tem
Lw hya fad

rear-> next newode TLw feba elenents


rear=newnode ?
doid disPlay
NOdetfroot
wbf le e t NulL) Cout <<t->data
tt next ?
Cout <c edl
int Delueue C)i isenits ()) Coutes'EmPty^3?
else ft ront =reac) lw Feha item
Idelete fronts wazcl
fro nt rears Nuli?
else Feta 2tr
*delPtr frt:
fronti Hw
Node
Prront s front-next3 delvaluesdelrtr ata;
deletedelPtrg
retum devalue

int Peek0E
return Front ->datas ?
int Count ()i iat Counterz 0j
Node * temP=root;
1
ohile Ct y=NUL)
Couter t+
t emP te?->next 3?
return Conters

You might also like