Stacks, Queues and Trees - tstorrnetnz/teaching2022 GitHub Wiki
Stacks, Queues and Trees
These are additional types of collections that you may find useful. They all are similar to array and arraylists in that they hold multiple elements of variables, classes etc.
Stacks
Imagine a stack of plates where the top plate is always the one that gets used first. The bottom plate will get used last of all. This is called a Last In First Out (LIFO) stack. A more detailed explanation is given here, as well as an example in Java.
Queues
A queue is simply what most of us imagine a queue to be - it is a First In First Out (FIFO) queue. A more detailed explanation is given here, as well as an example in Java.
Trees
Trees are a little more complicated - image them as a hierarchical set of relationships just like a family tree. A more detailed explanation is given here, as well as an example in Java.