Difference between stack and queue in data structure pdf
Stack has insertion and deletion in one end only. Queue has insertion in one end and deletion from othwr. A stack is an ordered list of elements where all insertions and deletions are made at the same end, whereas a queue is exactly the opposite of a stack which is open at both the ends meaning one end is used to insert data while the other to remove data.
The main difference between the two is their working mechanism. In queue Objects are inserted and removed from different ends. It points to the top of the stack. In queues, two different pointers are used for front and rear ends. In queues, the object inserted first is first deleted.
Queue operations are called enqueue and dequeue. Queues are visualized as horizontal collections. People standing in a file to board a bus is an example of queue. Dheeraj 11 Jul Stack — 1. It represents the collection of elements in Last In First Out order. Operations includes testing null stack, finding the top element in the stack, removal of top most element and adding elements on the top of the stack.
Queue - 1. It represents the collection of elements in First In First Out order. Operations include testing null queue, finding the next element, removal of elements and inserting the elements from the queue. Insertion of elements is at the end of the queue 4.
Deletion of elements is from the beginning of the queue. Insertion of elements is at the end of the queue Deletion of elements is from the beginning of the queue.
Other Related Discussions. Regarding for Data Structure. Stack Problem. How to create a Tree has more than 2 children in c data structure? The front pointer always points to the first element inserted in the list and is still present, and the rear pointer always points to the last inserted element.
Stack is used in solving problems works on recursion. Queue is used in solving problems having sequential processing. Previous Data Structures Queue Question 1. Next Data Structures Queue Question 2. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert.
Writing code in comment? Please use ide. Load Comments. What's New. Most popular in Data Structures. Name required. Email required. Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.
Notify me of followup comments via e-mail. Written by : Sagar Khillar. Data Structures and Algorithms in Java. Print [1]Langsam. Data Structures Using Java. New Delhi: Pearson Education India, Print [2]Dale, Nell, et al. User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.
What is a Stack? What is a Queue? Difference between Stack and Queue Meaning of Stack and Queue Stack is a basic data structure, an abstract data type represented by a linear structure resembling a physical stack where the object can be added at any time but can be removed which is added last. Working Principle in Stack and Queue Both stack and queue are non-primitive abstract data types in data structure served as a collection of objects in which the entities are stored in a particular order.
Structure of Stack and Queue The name stack refers to the analogy of a structure where the items are placed on top of each other like a stack like a packet of biscuits.
Applications of Stack and Queue One of the most primary applications of a stack data structure is the Depth-first search algorithm, which is based on the idea of backtracking mainly used for searching a graph or tree data structure. Stack vs. Queue: Comparison Chart Summary of Stack vs Queue Both stack and queue are non-primitive abstract data structures defined as a collection of objects organized in a particular order in a computer, but with different working principles.
Author Recent Posts. Sagar Khillar. Latest posts by Sagar Khillar see all.
0コメント