0% found this document useful (0 votes)
31 views2 pages

Ds Content

The document discusses stacks, queues, and deques. Stacks follow LIFO (last in, first out) where elements are inserted and removed from one end. Queues follow FIFO (first in, first out) where elements are inserted at one end and removed from the other. Deques allow insertions and removals from both ends and can simulate stacks and queues. Common operations for these data structures have O(1) time complexity. The document also provides examples of how stacks, queues, and trees/graphs are used in various applications such as expression conversion, resource scheduling, and data representation.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views2 pages

Ds Content

The document discusses stacks, queues, and deques. Stacks follow LIFO (last in, first out) where elements are inserted and removed from one end. Queues follow FIFO (first in, first out) where elements are inserted at one end and removed from the other. Deques allow insertions and removals from both ends and can simulate stacks and queues. Common operations for these data structures have O(1) time complexity. The document also provides examples of how stacks, queues, and trees/graphs are used in various applications such as expression conversion, resource scheduling, and data representation.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Stack and Queue

Stack:A stack is a linear list of elements for which all insertions and deletions(usually accesses) are made at only one end of the list. They are also called as LIFO lists(Last Input First Output). The operations supported are : 1)IsEmpty(S): returns whether the stack is empty or not. 2)IsFull(S): return whether the stack is full or not. 3)Push(Element X,S): pushes element X on to the top of the stack. 4)Pop(S) : pops an element from the top of the stack on to the output(printing on to the output console isn't necessary though in which case we can define another function Top(S) which gives the top element of the stack). All the above mentioned operations are of O(1) complexity.

Queue: Queue is a linear list for which all insertions are made at one end and deletions(accesses as well) are made at the other end of the list and the lists are also called as FIFO lists(First Input First Output ). The operations supported are 1)IsEmpty(Q):returns whether the queue is empty or not. 2)IsFull(Q): return whether the queue is full or not. 3)Enqueue(Element X,Q): inserts an element X on the rear side of the queue. 4)Dequeue(Q): removes the element pointed to by the front end of the queue. Similar to a stack ,the operations of the queue are also of O(1) complexity.

Dequeue (double ended queue):A Dequeue is a linear list for which insertions and deletions(accesses as well) occur at the ends. Analogous to the operations defined for stack and Queue,we can also define some

operations for Dequeue. A simple observation reveals the fact that we can simulate both stack and queue from Dequeue by input and output restrictions. Having dwelt at such a length on these linear lists,we shall also see some interesting questions based on the simple properties of these linear lists.

Application of Stacks and Queues: Stacks: 1. Stacks are used in conversion of expression from infix notation to postfix and prefix notation. 2. Stacks are used for evalaution of infix and postfix forms. 3. Stacks are used in tree traversal techniques. 4. Recursive functions are implemented using stacks. The copies of variables at each level of recursion are stored in stack. 5. Compiles use stacks in syntax analysis phase to check whether a particular in a program is syntactically correct or not. 6. Computers use stack during interrupt and function calls the information regarding actual parameters retrun a values retrun addresses and machine status is stored in stack. 7. Stacks are used in depth first search of a graph. Queues: 1. Queues are often in simulation of rear system when experimenting with real time system is expensive or dangerous. 2. Queues are used in breath first traversal. 3. In multiple programming system, different programs are put in queue and are executed one often another in their respective time solts. 4. In a computer network, different systems may request for same resource. In such a case resources requests are queue and serived one by one. Applications of Trees and graphs: Trees and graphs represent data in many domains in linguistics, vision, chemistry, web. Tree and graphs searching algorithms are used to retrieve information from the data.

You might also like