reading-notes

View on GitHub

Stacks and Queues

Stacks

image

A stack is a data structure that consists of Nodes. Each Node references the next Node in the stack

Common terminology for a stack :

you would check isEmpty before pop – Top – peak functions

FILO (First In Last Out) : that mean that first item added in the stack will be the last item popped out of the stack

Steps to add new item to Stack :

Steps to remove top item from Stack :

When you pop something from the stack , the item that will removed is last one appended

## Queues

image

The principle of FIFO (First In First Out) is applied to Queue

process of adding a Node to a queue: