Stack:a list of elements where insertion (push) or deletion (pop) is and can only be done
at one same end.
the bookish name of it is
LIFO. stands for
Last In First Out.
special terminology:
- push: to insert any element into the stack.
- pop ; to delete any element from the stack.
example:its like a
cookie jar. Top most cookie in the jar is only accessible.
application:the whole
"UNDO" concept or the thing we do by pressing
CTRL+ Z is done by
stack, or like in Maze puzzles.
Queue;
linear list of elements where insertion (rear) and deletion (front) can only be done by
different ends.
bookish name of it is
FIFO, stands for
First In First Out. queue has
head and
tail.
special terminology:
- enqueue (rear) : to operate insertion operation.
- dequeue (front): to operate deletion operation.
example:
like people waiting in a
line for movie tickets, new ( or last) person will stand at the end of the line every time. or like a fancy restaurant where i can enter and get out using 2 different way, and can't mess it up :P .
application:like in BFS( breadth first search) or DFS( deapth first search).