stack data structure jnv chandrpur maharastra.pptx
PradeepVithule
15 views
30 slides
Aug 01, 2024
Slide 1 of 30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
About This Presentation
stack data structure jnv chandrapur
Size: 670.49 KB
Language: en
Added: Aug 01, 2024
Slides: 30 pages
Slide Content
Prepared By : Group - 1 TOPIC :-”DATA STRUCTURES” Class - XII Subject - Computer Science (083) Board : CBSE
DATA STRUCTURES It represents how data is stored/ organized in computers memory .
Definition:- A data structure defines a mechanism to store, organize and access data along with operations that can be efficiently performed on the data.
DATA STRUCTURES:- For example, string is a data structure containing a sequence of elements where each element is a character. On the other hand, list is a sequence data structure in which each element may be of different types. We can apply different operations like reversal, slicing, counting etc. on list and string. Hence, a data structure organises multiple elements in a way so that certain operations on each element as well as collective data unit could be performed easily.
Implementation of Data S tructures can be done in two ways:-
STACK Stack is a Linear Data Structure. Stack is a list of elements in which an element may be inserted or deleted only at one end, called the TOP of stack. It follows the principle LAST IN FIRST OUT (LIFO). LIFO means the element inserted last would be the first to be deleted .
STACK
OPERATIONS ON STACK:- PUSH POP
OPERATIONS ON STACK:- There are mainly two types of operations that can be performed with stack- PUSH- Insertion of an element on the top of the stack is called Push . POP- Removal of an element from the top of the stack is called Pop. Push and Pop operations are done from single end called TOP.
Stack Push Operation:-
Stack POP Operation:-
OVERFLOW It refers to a situation, when one tries to push an element in stack, that is already full. In python,( for stacks implemented as list), since list grows, overflow condition does not arise until all memory is exhausted .
UNDERFLOW It refers to a situation when one tries to pop/ delete an item from an empty stack. That is stack is currently having no item and still one tries to pop an item.
STACK APPLICATIONS- Reversing a line Polish strings
REVERSAL OF LINE
polish notation-
EVALUATION OF POSTFIX EXPRESSION:- Read all the symbols one by one from left to right in the given Postfix Expression If the reading symbol is operand, then push it on to the Stack. If the reading symbol is operator (+ , - , * , / etc.,), then perform TWO pop operations and store the two popped operands in two different variables (operand1 and operand2). Then perform reading symbol operation using operand1 and operand2 and push result back on to the Stack. Finally! perform a pop operation and display the popped value as final result.
Example Postfix Notation
QUIZ TIME: Q1 . Process of inserting an element in stack is called ____________ a) Create b ) Push c) Evaluation d ) Pop
Question - 2 Q2. Process of removing an element from stack is called __________ a) Create b) Push c) Evaluation d) Pop
Question - 3 In a stack, if a user tries to remove an element from an empty stack it is called _________ a) Underflow b) Empty collection c) overflow d) Garbage collection .
Question - 4 Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________ a) Overflow b) Crash c) Underflow d) User flow
Question - 5 Q5. STACK is a LIFO or FIFO list?
ASSIGNED WORK Q1.EVALUATE the Postfix Expression AB+C*D/ if A=2, B=3, C=4 and D=5. Q2Given a Bounded stack of capacity 4 which is initially empty, draw pictures of the stack after each of the following steps. Stack is empty Push a Push b Push c Pop Push d pop