• Register
Welcome to the Question Answers about All Engineering Fields. Please use search option at the top right before asking questions.

Recent Badges

Notable Question
- eng.kobas -
Notable Question
- eng.kobas -
Notable Question
- Saba Khan -
100 Club
- yolandayy -
Notable Question
- hassan -
Notable Question
- Saba Khan -
Notable Question
- mfby2k -
Famous Question
- mfby2k -
100 Club
- A0948 -

Difference between stack and queue?

0 votes
Be the first
What are the main differences between stack and queue?
asked Jun 5, 2013 in Computer Engineering by Saba Khan  

2 Answers

+1 vote
Be the first
 
 

The difference between stack and queue is how they are removed. In a stack the last in will be the first one out (LIFO). In a queue it is first in is the first out (FIFO).

      

In a stack adding or deleting can only be done from the end called the top. In a queue adding is done at the end and removing is done from the front.

          

 

 
answered Jun 13, 2013 by sheebaaltaf  
0 votes
Be the first

Stack :

A stack can be compared to a bottle that is filled with stones. The only way to access the bottom stone is to remove the top stone one by one. So the stone that has gone in first is the last to come out .

Stack is a collection of objects that works in LIFO (Last in First out) mechanism while Queue is FIFO (First in First out). This means that the object that is inserted first is removed last in a stack while an object that is inserted first is removed first in a queue.

Queue :

A queue can be compared to a queue at a bus stop - people board the bus in the order they arrive to the bus stop and join the queue. So the first person to join the queue is the first person to board the bus.

A Queue is a first-in, first-out data structure that pops elements in the same order than they were pushed

 

 

 

 

 

 

answered Jun 13, 2013 by saif hassan  

Related questions

0 votes
Be the first
1 answer 1,155 views
+1 vote
Be the first
1 answer 249 views
0 votes
Be the first
0 answers 26 views
0 votes
Be the first
0 answers 30 views
Welcome to All Engineering Questions Answers QnA, where you can ask questions and receive answers from other members of the community.
...