Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the basic difference between stack and queue?

Tags:

stack

queue

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.

like image 476
Harish Rachakonda Avatar asked Jun 11 '12 05:06

Harish Rachakonda


People also ask

What is a stack and queue?

It performs mainly two operations, enqueue and dequeue. The enqueue operation performs the insertion of the elements in a queue while the dequeue operation performs the deletion of the elements from the queue. Examination of the empty condition. If top==-1, which means that the stack is empty.

What is the difference between queue and stack Mcq?

C. Queues use two ends of the structure; stacks use only one.


1 Answers

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.

like image 177
jhonkola Avatar answered Oct 08 '22 01:10

jhonkola



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!