SlideShare uma empresa Scribd logo
1 de 70
Ms.M.Karthiga
AP/CSE
EVOCATION
 To apply the stack operations for solving
various applications.
1. Classify the various applications of Stack ADT.
(U/C)
2. Convert an infix expression to postfix
expression using Stack Data Structure. (Ap/C)
3. Compute the given postfix expression using
Stack ADT. (Ap/C)
4. Demonstrate backtracking approach using
Stack ADT with examples. (Ap/C)
Four common stack applications are:
 Reversing data,
 Parsing,
 Postponing and
 Backtracking
 Reversing - {1 2 3 4} becomes {4 3 2 1}
Examples:
 Reversing a list
 Convert decimal to binary
91 16 7 5 3
Pseudocode
1 read (number)
2 loop (number > 0)
1 set digit to number modulo 2
2 print (digit)
3 set number to quotient of number / 2
3 end loop
Input:10
Output:0101 which is reverse of 1010STACK
 Parsing is any logic that breaks an expression of
data into independent pieces for further
processing.
 One common programming problem is
unmatched parentheses in an algebraic
expression.
 When parentheses are unmatched, two types
of errors can occur: the opening parenthesis
can be missing or the closing parenthesis can
be missing
Solution using STACK:
 Whenever we find an opening parentheses in
a program, we push it into the stack.
 When we find a closing parentheses, we pop
its matching opening parentheses from the
stack
 A stack can be useful when the application
requires that the use of data be postponed
for a while.
Examples:
 Infix to postfix transformation
 Postfix expression evaluation
Formats for arithmetic expressions:
1. Infix expression
 The operator comes between the operands.
 Ex: A+B
2. Prefix expression
 The operator comes before the operands.
 Ex: +AB
3. Postfix expression
 The operator comes after the operands.
 Ex: AB+
In the infix notation, we need to use
parentheses to control the evaluation
of the operators.
We thus have an evaluation method that
includes parentheses and two operator
priority classes.
 Priority 2 : * /
 Priority 1 : + -
 Priority 0 : (
1. Fully parenthesize the expression using any
explicit parentheses and the arithmetic
precedence.
2. Change all infix notations in each
parenthesis to postfix notation, starting
from the innermost expressions.
Conversion to postfix notation is done by
moving the operator to the location of the
expression’s closing parenthesis.
3. Remove all parentheses.
Infix expression  A+B*C
 Step 1
 (A+(B*C))
 Step 2
 (A+(BC*))
 (A(BC*)+)
 Step 3
 ABC*+  Postfix expression
Infix expression  (A+B)*C+D+E*F-G
 Step 1
 (((((A+B)*C)+D)+(E*F))-G)
 Step 2
 (((((AB+)*C)+D)+(EF*))-G)
 (((((AB+)C*)+D)+(EF*))-G)
 (((((AB+)C*)D+)+(EF*))-G)
 (((((AB+)C*)D+)(EF*)+)-G)
 (((((AB+)C*)D+)(EF*)+)G-)
 Step 3
 AB+C*D+EF*+G-  Postfix expression
 Keep track of operators in the infix expression
 If any operand is found, append it to the output
expression
 If any operator is found, push it into the stack
such that:
 If its priority is higher than the operator at the
top of the stack, go ahead and push it onto the
stack.
 If the current operator’s priority is lower than
or equal to that of the operator at the top of
the stack than, then top operator is popped out
of stack and placed in the output expression;
thus the current operator becomes top operator.
 Conversion of Infix to Postfix
 Step 1: Consider the next element in the input.
 Step 2: If it is operand, display it.
 Step 3: If it is opening parenthesis, insert it on
stack.
 Step 4: If it is an operator, then If stack is empty,
insert operator on stack.
 If the top of stack is opening parenthesis, insert the
operator on stack
 If it has higher priority than the top of stack, insert the
operator on stack.
 Else, delete the operator from the stack and display it,
repeat Step 4
 Step 5: If it is a closing parenthesis, delete
the operator from stack and display them
until an opening parenthesis is encountered.
Delete and discard the opening parenthesis.
 Step 6: If there is more input, go to Step
 Step 7: If there is no more input, delete the
remaining operators to output.
 Infix  A+B*C-D/E
 Postfix ABC*+DE/-
3*3/(4-1)+6*2 expression into postfix form
So, the Postfix Expression is 33*41-/62*+
 Backtracking is another stack use found in
applications such as computer gaming,
decision analysis, and expert systems.
Examples:
 Goal Seeking
 Eight Queens Problem
 The postfix form of the expression
(A+B)∗(C∗D-E)∗F/G is:
A) AB+CD ∗ E−FG/∗∗
B) AB+CD ∗ E−F∗∗G/
C) AB+CD ∗ E−∗F∗G/
D) AB+CDE∗ −∗F∗G/
A) AB+CD ∗ E−FG/∗∗
 The postfix expression for the infix
expression a+b*(c+d)/f+d*e is:
A) ab+cd+*f/d+e*
B) abcd+*f/+de*+
C) a*b+cd/f*de++
D) both (B) and (C)
 B)abcd+*f/+de*+
 Evaluate the postfix expression:
5 2 / 4 + 5 * 2 +
 Ans:32
Applications of stack
Reversing data
Reversing list
Convert decimal to binary
Parsing
Unmatched Parentheses
Postponement
Infix to postfix conversion
Evaluating postfix expression
Backtracking
Goal seeking
Eight queens problem
STACK
Definition
Operations
Implementation using array
PUSH POP STACK TOP
 Stack
 Definition
 Operations
 Push
 Pop
 Stack top
 Stack implementation using array
 Stack implementation using Linked List
Topic 2_revised.pptx

Mais conteúdo relacionado

Semelhante a Topic 2_revised.pptx

Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf
aniarihant
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
maxinesmith73660
 
computer notes - Conversion from infix to postfix
computer notes - Conversion from infix to postfixcomputer notes - Conversion from infix to postfix
computer notes - Conversion from infix to postfix
ecomputernotes
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
 

Semelhante a Topic 2_revised.pptx (20)

Linear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdfLinear Data Structures_SSD.pdf
Linear Data Structures_SSD.pdf
 
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
 
Stack application
Stack applicationStack application
Stack application
 
2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf2. Stack. Write a program that uses the stack class (you can use.pdf
2. Stack. Write a program that uses the stack class (you can use.pdf
 
Lect-5 & 6.pptx
Lect-5 & 6.pptxLect-5 & 6.pptx
Lect-5 & 6.pptx
 
additional.pptx
additional.pptxadditional.pptx
additional.pptx
 
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docxConsider this code using the ArrayBag of Section 5.2 and the Locat.docx
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
 
computer notes - Conversion from infix to postfix
computer notes - Conversion from infix to postfixcomputer notes - Conversion from infix to postfix
computer notes - Conversion from infix to postfix
 
Increment and Decrement operators in C++
Increment and Decrement operators in C++Increment and Decrement operators in C++
Increment and Decrement operators in C++
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxApplication of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
 
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
 
Theory of automata and formal language lab manual
Theory of automata and formal language lab manualTheory of automata and formal language lab manual
Theory of automata and formal language lab manual
 
C Operators
C OperatorsC Operators
C Operators
 
Programming Homework Help
Programming Homework Help Programming Homework Help
Programming Homework Help
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 

Mais de JAYAPRIYAR7

Mais de JAYAPRIYAR7 (17)

1.5 Energy Resources.ppt
1.5 Energy Resources.ppt1.5 Energy Resources.ppt
1.5 Energy Resources.ppt
 
1.3 Incremental Model.pptx
1.3 Incremental Model.pptx1.3 Incremental Model.pptx
1.3 Incremental Model.pptx
 
1.1 The nature of software.ppt
1.1 The nature of software.ppt1.1 The nature of software.ppt
1.1 The nature of software.ppt
 
1.2 Waterfall model.pptx
1.2 Waterfall model.pptx1.2 Waterfall model.pptx
1.2 Waterfall model.pptx
 
1.4 Prototyping model.pptx
1.4 Prototyping model.pptx1.4 Prototyping model.pptx
1.4 Prototyping model.pptx
 
1.5 Spiral model.pptx
1.5 Spiral model.pptx1.5 Spiral model.pptx
1.5 Spiral model.pptx
 
JP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.pptJP ASSIGNMENT SERIES PPT.ppt
JP ASSIGNMENT SERIES PPT.ppt
 
Physiology_Endocrinology.ppt
Physiology_Endocrinology.pptPhysiology_Endocrinology.ppt
Physiology_Endocrinology.ppt
 
ICMRI PPT Template.pptx
ICMRI PPT Template.pptxICMRI PPT Template.pptx
ICMRI PPT Template.pptx
 
Indian Space Programme JP PPT.pptx
Indian Space Programme JP PPT.pptxIndian Space Programme JP PPT.pptx
Indian Space Programme JP PPT.pptx
 
ARCATHON SAMPLE PPT (REFERENCE MODEL).pptx
ARCATHON SAMPLE PPT (REFERENCE MODEL).pptxARCATHON SAMPLE PPT (REFERENCE MODEL).pptx
ARCATHON SAMPLE PPT (REFERENCE MODEL).pptx
 
SPEAKING ASSESSMENT PPT .pptx
SPEAKING ASSESSMENT PPT .pptxSPEAKING ASSESSMENT PPT .pptx
SPEAKING ASSESSMENT PPT .pptx
 
Engineering Students - Idea Submission Template.pptx
Engineering Students - Idea Submission Template.pptxEngineering Students - Idea Submission Template.pptx
Engineering Students - Idea Submission Template.pptx
 
TECH WARRIORS_INNOVATE FOR SOCIETY.pptx
TECH WARRIORS_INNOVATE FOR SOCIETY.pptxTECH WARRIORS_INNOVATE FOR SOCIETY.pptx
TECH WARRIORS_INNOVATE FOR SOCIETY.pptx
 
BOB_Sample_PPt_Template_(1).pptx
BOB_Sample_PPt_Template_(1).pptxBOB_Sample_PPt_Template_(1).pptx
BOB_Sample_PPt_Template_(1).pptx
 
coursera1.pdf
coursera1.pdfcoursera1.pdf
coursera1.pdf
 
neurotansmitters.ppt
neurotansmitters.pptneurotansmitters.ppt
neurotansmitters.ppt
 

Último

Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
amitlee9823
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
amitlee9823
 
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
gajnagarg
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
amitlee9823
 

Último (20)

Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
 
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
Just Call Vip call girls kakinada Escorts ☎️9352988975 Two shot with one girl...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning Approach
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 

Topic 2_revised.pptx

  • 3.
  • 4.  To apply the stack operations for solving various applications.
  • 5. 1. Classify the various applications of Stack ADT. (U/C) 2. Convert an infix expression to postfix expression using Stack Data Structure. (Ap/C) 3. Compute the given postfix expression using Stack ADT. (Ap/C) 4. Demonstrate backtracking approach using Stack ADT with examples. (Ap/C)
  • 6.
  • 7. Four common stack applications are:  Reversing data,  Parsing,  Postponing and  Backtracking
  • 8.  Reversing - {1 2 3 4} becomes {4 3 2 1} Examples:  Reversing a list  Convert decimal to binary
  • 9.
  • 10. 91 16 7 5 3
  • 11. Pseudocode 1 read (number) 2 loop (number > 0) 1 set digit to number modulo 2 2 print (digit) 3 set number to quotient of number / 2 3 end loop Input:10 Output:0101 which is reverse of 1010STACK
  • 12.
  • 13.  Parsing is any logic that breaks an expression of data into independent pieces for further processing.  One common programming problem is unmatched parentheses in an algebraic expression.  When parentheses are unmatched, two types of errors can occur: the opening parenthesis can be missing or the closing parenthesis can be missing
  • 14.
  • 15. Solution using STACK:  Whenever we find an opening parentheses in a program, we push it into the stack.  When we find a closing parentheses, we pop its matching opening parentheses from the stack
  • 16.
  • 17.  A stack can be useful when the application requires that the use of data be postponed for a while. Examples:  Infix to postfix transformation  Postfix expression evaluation
  • 18. Formats for arithmetic expressions: 1. Infix expression  The operator comes between the operands.  Ex: A+B 2. Prefix expression  The operator comes before the operands.  Ex: +AB 3. Postfix expression  The operator comes after the operands.  Ex: AB+
  • 19. In the infix notation, we need to use parentheses to control the evaluation of the operators. We thus have an evaluation method that includes parentheses and two operator priority classes.  Priority 2 : * /  Priority 1 : + -  Priority 0 : (
  • 20. 1. Fully parenthesize the expression using any explicit parentheses and the arithmetic precedence. 2. Change all infix notations in each parenthesis to postfix notation, starting from the innermost expressions. Conversion to postfix notation is done by moving the operator to the location of the expression’s closing parenthesis. 3. Remove all parentheses.
  • 21. Infix expression  A+B*C  Step 1  (A+(B*C))  Step 2  (A+(BC*))  (A(BC*)+)  Step 3  ABC*+  Postfix expression
  • 22. Infix expression  (A+B)*C+D+E*F-G  Step 1  (((((A+B)*C)+D)+(E*F))-G)  Step 2  (((((AB+)*C)+D)+(EF*))-G)  (((((AB+)C*)+D)+(EF*))-G)  (((((AB+)C*)D+)+(EF*))-G)  (((((AB+)C*)D+)(EF*)+)-G)  (((((AB+)C*)D+)(EF*)+)G-)  Step 3  AB+C*D+EF*+G-  Postfix expression
  • 23.  Keep track of operators in the infix expression  If any operand is found, append it to the output expression  If any operator is found, push it into the stack such that:  If its priority is higher than the operator at the top of the stack, go ahead and push it onto the stack.  If the current operator’s priority is lower than or equal to that of the operator at the top of the stack than, then top operator is popped out of stack and placed in the output expression; thus the current operator becomes top operator.
  • 24.  Conversion of Infix to Postfix  Step 1: Consider the next element in the input.  Step 2: If it is operand, display it.  Step 3: If it is opening parenthesis, insert it on stack.  Step 4: If it is an operator, then If stack is empty, insert operator on stack.  If the top of stack is opening parenthesis, insert the operator on stack  If it has higher priority than the top of stack, insert the operator on stack.  Else, delete the operator from the stack and display it, repeat Step 4
  • 25.  Step 5: If it is a closing parenthesis, delete the operator from stack and display them until an opening parenthesis is encountered. Delete and discard the opening parenthesis.  Step 6: If there is more input, go to Step  Step 7: If there is no more input, delete the remaining operators to output.
  • 26.  Infix  A+B*C-D/E  Postfix ABC*+DE/-
  • 27. 3*3/(4-1)+6*2 expression into postfix form So, the Postfix Expression is 33*41-/62*+
  • 28.  Backtracking is another stack use found in applications such as computer gaming, decision analysis, and expert systems. Examples:  Goal Seeking  Eight Queens Problem
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.  The postfix form of the expression (A+B)∗(C∗D-E)∗F/G is: A) AB+CD ∗ E−FG/∗∗ B) AB+CD ∗ E−F∗∗G/ C) AB+CD ∗ E−∗F∗G/ D) AB+CDE∗ −∗F∗G/
  • 61. A) AB+CD ∗ E−FG/∗∗
  • 62.  The postfix expression for the infix expression a+b*(c+d)/f+d*e is: A) ab+cd+*f/d+e* B) abcd+*f/+de*+ C) a*b+cd/f*de++ D) both (B) and (C)
  • 64.  Evaluate the postfix expression: 5 2 / 4 + 5 * 2 +
  • 66.
  • 67. Applications of stack Reversing data Reversing list Convert decimal to binary Parsing Unmatched Parentheses Postponement Infix to postfix conversion Evaluating postfix expression Backtracking Goal seeking Eight queens problem
  • 69.  Stack  Definition  Operations  Push  Pop  Stack top  Stack implementation using array  Stack implementation using Linked List