Stacks and Queues
Stacks
Stacks are like stacks when talking about function calls. Stacks are a data structure mimicking an stacked set object that only allows someone to modify it by manipulating the top of the stack. You can only ever remove what is at the top of the stack, when adding things to the stack the newest item will always be at the top.
Methods of a Stack
- Push adds a new node to the top of the stack
- Pop removes the top Node from the stack
- Peek returns the value of the top Node in the stack
- IsEmpty returns Boolean value if the stack is empty or not
Queues
A queue is the same as a line. The first thing that comes into the queue will be the first thing to come out.
Methods of a Queue
- Enqueue allows you to input a value to the rear of the queue
- Dequeue allows you to remove a value from the front of the queue
- Peek returns the value of the front of the queue
- IsEmpty returns boolean value if queue is empty or not