2. Stack ADT
• Stack is a linear data structure in which the insertion and
deletion operations are performed at only one end. In a stack,
adding and removing of elements are performed at a single
position which is known as "top“
• In stack, the insertion and deletion operations are performed
based on LIFO (Last In First Out) principle or FILO(First In Last
Out).
5. Applications of stack
• used for expression evaluation.
• used to check parenthesis matching in an
expression.
• used for Conversion from one form of
expression to another.
• used for Memory Management.
• used in backtracking problems.
• https://www.youtube.com/watch?v=d_XvFOkQz
5k
8. Conversion of infix to postfix
• Place parentheses around every group of operators in the
correct order of evaluation. There should be one set of
parentheses for every operator in the infix expression
• ((A * B) + (C / D))
• For each set of parentheses, move the operator from the
middle to the end preceding the corresponding closing
parenthesis.
• ((A B *) (C D /) +)
• Remove all of the parentheses, resulting in the equivalent
postfix expression.
• A B * C D / +
9. Evaluating arithmetic
expressions
Input Stack
2 3 4 * + empty Push 2
3 4 * + 2 Push 3
4 * + 3 2 Push 4
* + 4 3 2 Pop 4 and 3, and
perform 4*3 = 12.
Push 12 into the
stack.
+ 12 2 Pop 12 and 2 from
the stack, and
perform 12+2 = 14.
Push 14 into the
stack.
1) Postfix expression: 2 3 4 * +
10. Input Stack
3 4 * 2 5 * + empty Push 3
4 * 2 5 * + 3 Push 4
*2 5 * + 4 3 Pop 3 and 4 from the stack
and perform 3*4 = 12. Push
12 into the stack.
2 5 * + 12 Push 2
5 * + 2 12 Push 5
*+ 5 2 12 Pop 5 and 2 from the stack
and perform 5*2 = 10. Push
10 into the stack.
+ 10 12 Pop 10 and 12 from the
stack and perform 10+12 =
22. Push 22 into the stack.
2 )Postfix expression: 3 4 * 2 5 * +
11. Queue ADT
• Queue data structure is a collection of similar data items
in which insertion and deletion operations are performed
based on FIFO principle
12. Operations
1.enQueue(value) - (To insert an element into the queue)
2.deQueue() - (To delete an element from the queue)
3.display() - (To display the elements of the queue)
4.Queue() – creates a new empty queue
5.isEmpty()-returns a boolean value
6.Length()-returns the number of items currently in the
queue
https://www.geeksforgeeks.org/array-implementation-of-queue-
simple/
13. Circular queue
• A circular queue is a linear data structure in which the
operations are performed based on FIFO (First In First Out)
principle and the last position is connected back to the first
position to make a circle.
14. Priority queue
• Every item has a priority associated with it.
• An element with high priority is dequeued before an element
with low priority.
• If two elements have the same priority, they are served
according to their order in the queue.
Types:
1)Bounded priority queue - small limited range of p priorities
over the interval of integers [0 . . . P]
2)Unbounded priority queue - no limit on the range of integer
values
15. Doubly Ended queue(Deque)
• It allows insertion and removal of elements from
both the ends, i.e , front and back.
16. Applications of Queue
• In operating systems like Semaphores,FCFS, Buffer for
devices
• CPU task scheduling
• In networks like mail queues, queues in routers/switches
Real time application
• call center phone system to hold the calls