View on GitHub

reading-notes

Stack and Queue Reading Notes

Home

Stacks

A stack is a data structure that consists of nodes, and each node references the next node in the stack, but not it’s previous.

Push - nodes or items that are put into a stack

Pop - nodes ore items that are removed from a stack

Top - top of the stack

Peek - views the value at the top of the stack

IsEmpty - returns true when the stack is empty

Stacks are FILO - First In Last Out as well as LIFO - Last In First Out

Queues

Queues are FIFO (First In Last Out) as well as LILO (Last In Last Out).

Enqueue - adding an item to a queue.

Dequeue - removing an item from a queue.

Peek - inspecting the front node of a queue.