Java / Collections
What is the difference between Queue and Stack?
Queue is a data structure which is based on FIFO (first in first out). e.g. in the real world, who gets into the ticket counter queue gets the ticket and leave the queue.
Stack is a data structure which is based on LIFO (last in first out). e.g. stacked plates, where we need to remove the top plates to access the plate from the middle of the plates. Also Towers of Hanoi problem is an example of stack.
More Related questions...