7-2-data-structures-ii-stacks-queues.pptx

RajeshRanjan946150 9 views 9 slides Jul 07, 2024
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

For CBSE Class 12 Computer Science Students


Slide Content

Data Structures-II Stack & Queues CHAPTER – 7.2

S t a cks Stack is a linear structure in which insertion and deletion occur in LIFO pattern The end of the stack in which these operation s occur is called top of stack Any data can inserted or deleted only through the top Deletion is called pop and insertion is called push Some other terminologies used with stack are: peek , overflow, underflow

Implementation of Stacks in Python P ee k < stack>[top] Push < stack>.append(<item>) Pop < stack>.pop()

Stack Implementation in Python

Applications of stack To reverse a String : When we push every letter of a string till the last character and pop them back we get the string in reverse For polish notation : Stack plays a vital role in solving complex arithmetic expressions in any high-level language . For this stack is used to convert an expression in infix notation to postfix and vice versa. K C A T S

Infix to postfix

postfix Solve- 60,6,/,5,2,*,5,-,+

Infix to postfix

Solving Postfix