Stacks & Queues
Sound a lot like a link list?
FILO - First In Last Out
LIFO - ^^reverse
The Stack
It looks to operate like a link list accept your working on the active end of the stack or the (tail).
Also I find it a bit odd that the term “head” is used when it is so closely related to data storage and the active component(or location) of a storage system (i.e. HDD). Strange no?
Push
- Push is O(1)
- adds value to the stack pointing to the previous value
- then it is set to “new Top”
Pop
- selects top node and “removes” it for processing and completetion
Peek
- simply chekcing the stack to see whats there and maybe also whats “next”
IsEmpty
- yeah what is says.
The Queue
- FiFo
- LiLo
Enqueue
- Add to the stack. the first becoming the “rear”
Dequeue
- to Pull of the stack the node at the Front
Front
- active end of the stack with.
Rear
- starting point of the stack
Peek
- to check whats next, usually you check isempty first
IsEmpty
- using the next value it checks to see if there is another value in the stack