Stacks
Pseudocode for size()
Returns number of elements in stack, does this by increasing top pointer by 1 (First element in position 0)
Pseudocode for isEmpty()
Checks if the stack is empty, does this by checking if the pointer is less than 0 (If its 0 there is one item in the stack)
Pseudocode for peek()
Pseudocode for push()
Pseudocode for pop()
Example of a Stack
Queues
Pseudocode for size()
Pseudocode for isEmpty()
When queue is empty, front and back should be the same value, check if this is the case to determine if the queue is empty
Pseudocode for peek()
Peek returns element at the front of the queue without removing it
Pseudocode for enqueue(element)
To add an element, element placed in position of back pointer, back pointer is then incremented by 1
Pseudocode for dequeue()
Items removed from queue from position of front pointer, important to check if queue is empty before doing so to avoid an error
Example of a Queue
What happens if the following operations are ran on the queue above?
Linked Lists
Trees