Stack and Queue
Stack
followS a
Stack is a lineas data stxuctuxe that
0xdex in which the ope3ations
are pertormed.
paxticulax
LIFOCLast In Fivst Out)
0T
The Oxdex may be
Last Out).
FILO CFixst In
Push PoP C
C
c
ToP C B
B
A A
Stack Data Stzuctuae
stack.
Thexe ase many veal-lite examples of a
stacked over one
Conside an example 0 plates
canteen. The plate which is at the
another in the
i.e. the plate
top is the fiast one to be xemoved,
which has been placed at the bottom-most position
emains in the Stack for the longest peviod of time.
So, it can be simply Seen to follow LIFOCLast.In
Fist Out)
oxdex.
FILO CFiast In Last Out)
Shubham Upadhyay CLinkedIn)
Queue
A Queue is defined as a lineas datq structuze that
is Open at both ends and the opebations ae peafoamed
ordex.
in Fixst In Fixst Out CFI F0)
We define a queue to be a list in which all additions
tothe list aze made at one end, and all deletions
tsom the list ave made at the othe end. Thne
element which is first pushed into the ordez,
Ozdes
the operation is first performed on that
Frort/Head Back/Tail/ Kear
Dequeue
B45 Engueve
2
Queue Datq Structve
Charactesistics of Queue
Queue can handle multiple data.
We can access both ends.
fast and flexible.
Tne
They are
Shubham UpadhyayCLinkedIn)
Queue Representation
Like stacks, Queves Can also be vepresented in an
the Gueue is
aray In this Tepresentation, implemented
Vasiables used in this Case axe
USing the array
of the array queue elements.
storing
Queue. the name
the First element is stored
o Front: the îndex where
thequeue.
in the aray epvesenting
where the last
element is stored în an
Reas: the index
epresenting the queue.
arayaray
Such
such Notes.)
Notes:)
Foz moze
Follow 5hubham Upadhyay