Question

What is the difference between the stack and the queue when it comes to data storage?

Was it helpful?

Solution

A stack works like a tray of dirty dishes, the first one you put on the stack will be the last one out of the stack. The last one on the stack will be the first one popped off the stack (Last in first out).

The queue works in the same way a line at the supermarket works. The first one in a queue will be the first one out of the queue(First in first out).

OTHER TIPS

Stack - first in first out.

Queue - first in last out

Various methods to implement

Does that answer your homework

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top