answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

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

Wiki User

13y ago

An example of a stack is a stack of papers put on a table to be marked by a professor. Students place papers on top of the stack and the professor will, when marking, take papers from the top of the stack. An example of a queue is waiting in line at a shop or a bank: customers will be served in a first-in, first out fashion. If the people are busy then you have to wait in a queue.

This answer is:
User Avatar

User Avatar

Anonymous

Lvl 1
3y ago

for: write aprogram in c++ to remove all the even elements of the linked list without affecting the order of elemnts

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Basic operation of stack and Queue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is time complexity of stack?

All major queue operations (push, pop and front) are constant time operations.


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


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 a stack and how do you represent a stack in computer memory also discuss basic operation performed on a stack?

A stack is an abstraction of First-in-last-out, or the last in first out. The basic operations (may bear different names) Push or Add Pop or Next


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


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


What are the stack operation?

there are two operations you can do with a STACK one is PUSH operation and the other is POP operation


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


What is the meaning of popping in computer programming?

Popping is the opposite of pushing. You push values into a queue and pop them off. The queue is generally represented by a stack, where the last value pushed onto the stack is the first to be popped off the stack (last in first out, or LIFO).


Why an operation to check queue overflow is not implemented on linked queue?

In linked queue we're dynamically allocating the memory and there's no fixed memory limit in Linked Queue. That's why there's no operation for overflow. I guess It's the correct reason