What is the difference between Stack and Queue? - ProProfs Discuss
Advertisement

What is the difference between Stack and Queue?

Asked by Marlon , Last updated: Apr 17, 2024

+ Answer
Request
Question menu
Vote up Vote down

3 Answers

C. Block

C. Block

Find happiness in writing new things.

C. Block
C. Block, English Professor, M.A, Ph.D, Buffalo

Answered Aug 04, 2020

A stack is usually described as a linear data structure, and this is because of how it works. With stack, when retrieving data, the data that entered last will be the first to be retrieved. This is because it follows the "last in first out" principle. To understand this better, think of a stack as a container with an opening, the last item to be added to the container will always be the first to be retrieved or deleted.

When inserting data into the stack, the operation is called "push," and it is called "pop" when retrieving or deleting the data. In contrast, a queue uses a different principle entirely. In the queue, the first element to be added will be the first to be retrieved or deleted.

Elements are usually inserted from the rear, and they will be retrieved from the other side, which is the front. The principle used in the queue is "first in first out."

upvote downvote
Reply 

C. Marcus

C. Marcus

C. Marcus
C. Marcus, Content Developer, Washington

Answered Jul 23, 2020

Stack and quene are two types of data types that are abstract. A stack is physical and at the end, has insertion and deletion. Quene differs because the end of the quene is open. Stacks are quene are based off of two different working principals. Stack is based off the principal LIFO, which stands for last in, first out.

Quene is based off the principal FIFO, which stands for first in first out. Another difference between them is the amount of pointers that can be used. Stacks used one pointer, while Quene uses two pointers and the pointers used in quene are used only in a simple quene.

upvote downvote
Reply 

F. Daniel

F. Daniel

I work for a California based MNC.

F. Daniel
F. Daniel, Content Optimization Executive, Diploma in Journalism, California

Answered Jul 21, 2020

The stack is a linear data structure where data can be added and removed. With stack, the last added data item will be the first to be removed. This is because it uses one end to insert and remove objects. Queue, on the other hand, is similar to stack just that this data structure has two ends, which means the first data to be added at one end will be the first to be retrieved at the other end.

While both are used to store data the principle of the stack as explained above is "first in last out," whereas the principle of Queue is "first in first out," because the insertion of data or objects is taking place at one end while the other end is where these objects can be retrieved.

One of the problems with Stack is that the first data to be stored won't be accessed until those that were stored after it is retrieved. However, this might be the right option for you if you want the last object that you added.

upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.