answersLogoWhite

0


Best Answer

Queue is better than stack because jobs in a queue are processed on a first in first out order thereby reducing traffic and delay.

But jobs in a stack are processed in a last in first out order causing traffic and delay of jobs that arrived earlier

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

You can think of a queue like a line at the bank. The first person to get there will get to the teller first. If a bunch of people come while all the tellers are busy, they stand in line in the order in which they arrived. That is to say, new people (items) are added to the end of the line and the first person in line is the only one who is called to a teller. In real life this is known as "first come, first served." In programming terms it's known as first-in-first-out, or FIFO.

You can think of a stack like a deck of cards. You can put down cards into a pile on your table one at a time, but if you want to draw cards, you can only draw them from the top of the deck one at a time. Unlike a queue, the first card to be put down is the last card to be used. This is known as first-in-last-out, or FILO (also called LIFO for last-in-first-out).
A queue is a first-in-first-out data structure. When you add an element to the queue you are adding it to the end, and when you remove an element you are removing it from the beginning.

A stack is a first-in-last-out data structure. When you add an element to a stack you are adding it to the end, and when you remove an element you are removing it from the end.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

STACK uses the LIFO technique, where QUEUE uses FIFO technique.

LIFO means last in first out, FIFO means first in first out.

you can simply understand by a simple example that "if u puts balls inside a pipe whose one end is closed, so then the 1st ball entered to that pipe exit at last but the last ball exit 1st.".Its the example of stack."If u stand in a ticket counter then the 1st person always exit 1st ,the last person exit last" Its an example of queue.

IN data structure it same thing happens. In stack the 1st entered data outs last & queue the 1st entered data outs 1st.

In stack the data enters & outs by PUSH & POP operations respectively

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

in linear queue the condition for queue full is QREAR==MAXLIMIT

suppose maxlimit is ten and queue is full now if we delete 9 element from queue then inspite of queue is empty we can not insert any element in the queue. this wastage of memory is solved through circular queue where queue full condition is

QREAR==Qfront+1

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack. The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. types of queues : circular, linear, double ended and priority

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

It's not a question of which is better, but which one serves your need.

A stack is LIFO (last in first out), meaning that the most recent item you added to the stack, will be the first one you retrieve.

A queue is generally FIFO (first in first out), meaning that the first item you added to the stack (that you haven't retrieved yet), will be the first one you retrieve.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Some applications of stack are : Polish notation, reversing string, backtracking , quick sort algorithm etc. The queue is a linear data structure where operations od insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Whenever a new item is added to queue, rear pointer is used. and the front pointer is used when an item is deleted from the queue.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

In a queue, items are removed in order in which they were inserted (first in, first out). Conversely, a stack uses a last in, first out system.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between a queue and a stack?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between stack snd queue?

In stack , the object which is last in will be first out (LIFO), whereas in queue the object which is first in will be first out (FIFO).


What is the difference between stack and queue in a tabular form?

I want see them simultaneously


What difference between stack and queue?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Some applications of stack are : Polish notation, reversing string, backtracking , quick sort algorithm etc. The queue is a linear data structure where operations od insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Whenever a new item is added to queue, rear pointer is used. and the front pointer is used when an item is deleted from the queue.


What is the difference between a queue and a stack with example?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack. The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. types of queues : circular, linear, double ended and priority


Difference between a queue and a stack in brief?

In a queue, elements are placed in line; the first to get into the queue is the first to get out (FIFO - first in, first out).A stack is also a structure to store pieces of data, or objects, but the last element to get in will be the first element to get out (LIFO).In a queue, elements are placed in line; the first to get into the queue is the first to get out (FIFO - first in, first out).A stack is also a structure to store pieces of data, or objects, but the last element to get in will be the first element to get out (LIFO).In a queue, elements are placed in line; the first to get into the queue is the first to get out (FIFO - first in, first out).A stack is also a structure to store pieces of data, or objects, but the last element to get in will be the first element to get out (LIFO).In a queue, elements are placed in line; the first to get into the queue is the first to get out (FIFO - first in, first out).A stack is also a structure to store pieces of data, or objects, but the last element to get in will be the first element to get out (LIFO).


Why does LIFO order follows in stack and why does FIFO order follows in queue?

LIFO and stack are synonyms, so are FIFO and queue.


What are the different between stack and queue?

A stack is generally First In, Last Out, and a queue is First In First Out.Item can be added or removed only at one end in stack and in a queue insertion at the rear and deletion from the front.The basic operation of stack are 'push' and 'pop', on other hand of queue are 'enque' and 'dequeue'.


What is difference between job queue and ready queue?

Ready queue contain all the jobs that are ready to execute.so the job queue and the ready queue are one and the same.


Is cursor implementation possible in queue or stack?

yes,cursor implementation possible in priority queue.


Write a program in c language to reverse elements of a queue?

There are many ways to reverse the order of the elements in a queue. Provided that you have access to the implementation of the queue, it is of course easy to read the elements from the tail end rather than the front end, thus reversing the elements. However, considering the queue as a black box, and assuming the queue only allows for its characteristic operations (removal of head element, addition to tail), the best method to reverse the elements in a queue to engage a stack. You'd remove the elements from the queue (always reading the head of the queue), and push each element onto the stack. When the queue is empty, you reverse that process: pop each element from the stack until it is empty, and add each element in this order to the end of the queue. Your queue will have the exact same elements as in the beginning, but in reverse order. The exact implementation of this in C, or in any other programming language, is trivial, but the exact source code depends on the implementation of queue and stack containers. Following is pseudocode: Queue<Item> reverse (Queue<Item> queue) { Stack<Item> stack; Item item; while (queue.remove(&item)) { stack.push(item); } while(stack.pop(&item)) { queue.add(item); } return queue; }


Double ended stack?

Double ended queue


What to Compare and contrast between stack and queue?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Some applications of stack are : Polish notation, reversing string, backtracking , quick sort algorithm etc. The queue is a linear data structure where operations od insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. Whenever a new item is added to queue, rear pointer is used. and the front pointer is used when an item is deleted from the queue.