stack data structure jnv chandrpur maharastra.pptx

PradeepVithule 15 views 30 slides Aug 01, 2024
Slide 1
Slide 1 of 30
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
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30

About This Presentation

stack data structure jnv chandrapur


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

THANK YOU
Tags