answersLogoWhite

0


Best Answer
  • 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'.
User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
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

12y ago

A stack can be implemented as linear array or as a linked list

A queue can be implemented as a linear array or as a bidirectionally linked list.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the different between stack and queue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


Is cursor implementation possible in queue or stack?

yes,cursor implementation possible in priority queue.


Double ended stack?

Double ended 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; }


Similarities between stack n queue?

Abey kaminey, agar main jaanta to tere se puchhne jata.

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


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 is the use of queue?

The queue is the the concept involved in Algorithms where you use stack, queue and lists to store the different data items e.g people waiting for the bus at bus stop the first in queue will enter first this is called FIFO (first in first out).......


Is cursor implementation possible in queue or stack?

yes,cursor implementation possible in priority queue.


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).


Double ended stack?

Double ended 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; }


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.


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


Similarities between stack n queue?

Abey kaminey, agar main jaanta to tere se puchhne jata.