Stack and Queue

Stack concept
data struct which stores data in an ordered matter. It is a linear data structure, elements are added and removed only at one end, which i called top. In a linked list we can use  linked list to implement this data structure, we can push and pop from one end.
operation.
push(x) :- push a new element
pop():- remove an item from the top
top:- reveal the top element
Queue concept
elements are entered through the rear and leave through the front, it follows the FIFO(first in first out) concept.
we can use linked list to implement this data structure.
operation.
push(x):- push a new element through the rear
pop():- pop an element through the front
front():- return or reveal the front item

prefix :- operator is written before operand
infix :- operator is written between operand
postfix :- operator is written after operand

infix =  (10 + 5) * ( 10 - 5 ) / 2
prefix = * + 10 5 / - 5 10 2
postfix = 5 10 + 5 10 - 2 / *
// idk if i'm wrong but i try without cheating //





Komentar

Postingan populer dari blog ini

AVL and B3