What is the basic difference between stack and queue

queuestack

What is the basic difference between stack and queue??

Please help me i am unable to find the difference.

How do you differentiate a stack and a queue?

I searched for the answer in various links and found this answer..

In high level programming,

a stack is defined as a list or sequence of elements that is lengthened by placing new elements "on top" of existing elements and shortened by removing elements from the top of existing elements. It is an ADT[Abstract Data Type] with math operations of "push" and "pop".

A queue is a sequence of elements that is added to by placing the new element at the rear of existing and shortened by removing elements in front of queue. It is an ADT[Abstract Data Type]. There is more to these terms understood in programming of Java, C++, Python and so on.

Can i have an answer which is more detailed? Please help me.

Best Answer

Stack is a LIFO (last in first out) data structure. The associated link to wikipedia contains detailed description and examples.

Queue is a FIFO (first in first out) data structure. The associated link to wikipedia contains detailed description and examples.

Related Topic