I've previous learned the strut push/pop, last in first out data structure but I'm struggling to wrap my head around a queue data structure. All the videos I find confuse me.
I'm trying to answer this question.
what are the end results of a queue MyQ after the following sequence of operations?
I thought you always added new items to the back not the front?
You can push items to the front or the back of the container. A stack will always pull from the same side of the container as the elements were placed. A queue will pull from the opposite side of the container where the elements were placed.
what does push front mean
It means just what it says, push the item to the front of the queue.
Remember a stack is a First In First Out (FIFO) data structure. A queue is a Last In First Out (LIFO) data structure.
A stack is like a stack of plates that need washing. You start from the top, washing each dish you get, until you go to the bottom. Or stacked boxes, each on top of the other, and you need to move them. You start from the top.
A queue is like a queue in the supermarket waiting to pay for the products. If you get in the queue before the other person, you will pay before him and finish earlier.