SlideShare a Scribd company logo
1 of 16
STACKS
๏ƒ˜ INTRODUCTION
๏ƒ˜ HISTORY
๏ƒ˜ STACK
๏ƒ˜ PUSH , POP
๏ƒ˜ APPLICATION OF STACK
CONTENTS
A Stack is data structure in which
addition of new element or deletion of
existing element always takes place at a
same end. This end is known as the top of
the stack. That means that it is possible
to remove elements from a stack in
reverse order from the insertion of
elements into the stack.
INTRODUCTION
Stacks entered the computer science
literature in 1946, in the computer design
of Alan M. Turing (who used the terms
"bury" and "unbury") as a means of calling
and returning from subroutines Subroutine
had already been implemented in
KonradZuse in 1945. Klaus Samelso and
Friedrich L. Bauer of Technical University
Munich proposed the idea in 1955 and filed
a patent in 1957. The same concept was
developed, independently, by the Australian
Charles Leonard Hamblin in the first half of
1957.
HISTORY
Defination : Stack is a non primative and linear
data structure.
Operation of stack:
i)Insertion[PUSH( )] .
ii)Deletion [POP ( )].
iii)Top ( ).
iv)Empty( ).
v)Is Full( ).
STACK
It is a function that is used to insert items
into stack.
In PUSH there is a overflow of items in Stack.
If top =max then print STACK OVERFLOW
PUSH
It is a function used to delete items from
stack.
In POP there is underflow of items in stack.
If top=0 then print stack underflow.
POP
๏ƒ˜ REVERSING A LIST.
๏ƒ˜ POLISH NOTATION
๏ƒ˜ CONVERSION OF INFIX TO POSTFIX
EXPRESSION
๏ƒ˜ EVALUTION OF POSTFIX EXPRESSION
๏ƒ˜ CONVERSION OF INFIX TO PREFIX
EXPRESSION
๏ƒ˜ EVALUTION OF PREFIX EXPRESSION
๏ƒ˜ RECURSION
APPLICATION OF
STACK
It is the method of writing operation of
an expression neither before there
operants or after them is called polish
notation.
There are 3 types of polish notation:
i)Infix notation eg : A+B
ii)Prefix notation eg : +AB
iii)Postfix notation eg : AB+
POLISH
NOTATION
1) The order in which the operators appear is
not reversed.
2) When the '+' is read, it has lower
precedence than the '*', so the '*' must be
printed first.
3) We will show this in a table with three
columns. The first will show the symbol
currently being read.
4) The second will show what is on the stack
and the third will show the current contents
ALGORITHM :
INFIX TO POSTFIX
CONVERSION
CONVERSION OF INFIX TO
POSTFIX EXPRESSION
EXPRESSION : 1,2,3,*,+,4,-
FINAL ANSWER IS 3.
EVALUTION OF POSTFIX
EXPRESSION
1) Push โ€œ)โ€ onto STACK, and add โ€œ(โ€œ to end of
the A.
2) Scan A from right to left and repeat step 3
to 6 for each element of A until
the STACK is empty.
3) If an operand is encountered add it to B.
4) If a right parenthesis is encountered push
it onto STACK
ALGORITHM :
INFIX TO PREFIX
EXPRESSION
CONVERSION OF INFIX TO PREFIX
EXPRESSION
EXPRESSION : +,-,2,7,*,8,/,4,12
FINAL ANSWER IS 29
EVALUTION OF PREFIX
EXPRESSION
Recursion is an approach in which a
function calls itself with an argument.
Upon reaching a termination condition,
the control returns to the calling
function.
RECURSION

More Related Content

What's hot

Exercise6 ch2
Exercise6 ch2Exercise6 ch2
Exercise6 ch2
IIUM
ย 

What's hot (20)

Cad for vlsi design june2013 (2)
Cad for vlsi design june2013 (2)Cad for vlsi design june2013 (2)
Cad for vlsi design june2013 (2)
ย 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of Example
ย 
Pointers
PointersPointers
Pointers
ย 
Headerfiles
HeaderfilesHeaderfiles
Headerfiles
ย 
Write declarations for each of the following variables: a. amounts is a...
Write declarations for each of the following variables:       a. amounts is a...Write declarations for each of the following variables:       a. amounts is a...
Write declarations for each of the following variables: a. amounts is a...
ย 
Data Visualization With R: Introduction
Data Visualization With R: IntroductionData Visualization With R: Introduction
Data Visualization With R: Introduction
ย 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
ย 
Exercise6 ch2
Exercise6 ch2Exercise6 ch2
Exercise6 ch2
ย 
Cs6503 theory of computation november december 2016
Cs6503 theory of computation november december 2016Cs6503 theory of computation november december 2016
Cs6503 theory of computation november december 2016
ย 
Cs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paperCs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paper
ย 
Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015Cs2303 theory of computation november december 2015
Cs2303 theory of computation november december 2015
ย 
Applications of stack
Applications of stackApplications of stack
Applications of stack
ย 
Ternary operator
Ternary operatorTernary operator
Ternary operator
ย 
Data Visualization With R: Learn To Modify Color Of Plots
Data Visualization With R: Learn To Modify Color Of PlotsData Visualization With R: Learn To Modify Color Of Plots
Data Visualization With R: Learn To Modify Color Of Plots
ย 
Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...
ย 
Foundation of computing history final
Foundation of computing history finalFoundation of computing history final
Foundation of computing history final
ย 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
ย 
Stack
StackStack
Stack
ย 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
ย 
20181204i mlse discussions
20181204i mlse discussions20181204i mlse discussions
20181204i mlse discussions
ย 

Similar to Stacks

Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
ย 
Stack linked list
Stack linked listStack linked list
Stack linked list
bhargav0077
ย 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
prakashvs7
ย 

Similar to Stacks (20)

STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
ย 
CH4.pptx
CH4.pptxCH4.pptx
CH4.pptx
ย 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
ย 
stack & queue
stack & queuestack & queue
stack & queue
ย 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
ย 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
ย 
Stack
StackStack
Stack
ย 
5 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart25 chapter3 list_stackqueuepart2
5 chapter3 list_stackqueuepart2
ย 
Data structure day3
Data structure day3Data structure day3
Data structure day3
ย 
5.-Stacks.pptx
5.-Stacks.pptx5.-Stacks.pptx
5.-Stacks.pptx
ย 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
ย 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
ย 
stack.ppt
stack.pptstack.ppt
stack.ppt
ย 
Stack
StackStack
Stack
ย 
13 Stacks and Queues.pptx
13 Stacks and Queues.pptx13 Stacks and Queues.pptx
13 Stacks and Queues.pptx
ย 
STACK1.pptx
STACK1.pptxSTACK1.pptx
STACK1.pptx
ย 
Lecture_04.2.pptx
Lecture_04.2.pptxLecture_04.2.pptx
Lecture_04.2.pptx
ย 
Stack linked list
Stack linked listStack linked list
Stack linked list
ย 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
ย 
Concept of stack ,stack of aaray stack by linked list , application of stac...
Concept of stack ,stack of aaray   stack by linked list , application of stac...Concept of stack ,stack of aaray   stack by linked list , application of stac...
Concept of stack ,stack of aaray stack by linked list , application of stac...
ย 

Recently uploaded

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
ย 
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 

Recently uploaded (20)

Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
ย 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
ย 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
ย 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
ย 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
ย 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
ย 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
ย 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
ย 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
ย 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
ย 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
ย 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
ย 
Orlandoโ€™s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlandoโ€™s Arnold Palmer Hospital Layout Strategy-1.pptxOrlandoโ€™s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlandoโ€™s Arnold Palmer Hospital Layout Strategy-1.pptx
ย 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
ย 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
ย 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
ย 
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in South Ex (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
ย 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
ย 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
ย 

Stacks

  • 2. ๏ƒ˜ INTRODUCTION ๏ƒ˜ HISTORY ๏ƒ˜ STACK ๏ƒ˜ PUSH , POP ๏ƒ˜ APPLICATION OF STACK CONTENTS
  • 3. A Stack is data structure in which addition of new element or deletion of existing element always takes place at a same end. This end is known as the top of the stack. That means that it is possible to remove elements from a stack in reverse order from the insertion of elements into the stack. INTRODUCTION
  • 4. Stacks entered the computer science literature in 1946, in the computer design of Alan M. Turing (who used the terms "bury" and "unbury") as a means of calling and returning from subroutines Subroutine had already been implemented in KonradZuse in 1945. Klaus Samelso and Friedrich L. Bauer of Technical University Munich proposed the idea in 1955 and filed a patent in 1957. The same concept was developed, independently, by the Australian Charles Leonard Hamblin in the first half of 1957. HISTORY
  • 5. Defination : Stack is a non primative and linear data structure. Operation of stack: i)Insertion[PUSH( )] . ii)Deletion [POP ( )]. iii)Top ( ). iv)Empty( ). v)Is Full( ). STACK
  • 6. It is a function that is used to insert items into stack. In PUSH there is a overflow of items in Stack. If top =max then print STACK OVERFLOW PUSH
  • 7. It is a function used to delete items from stack. In POP there is underflow of items in stack. If top=0 then print stack underflow. POP
  • 8. ๏ƒ˜ REVERSING A LIST. ๏ƒ˜ POLISH NOTATION ๏ƒ˜ CONVERSION OF INFIX TO POSTFIX EXPRESSION ๏ƒ˜ EVALUTION OF POSTFIX EXPRESSION ๏ƒ˜ CONVERSION OF INFIX TO PREFIX EXPRESSION ๏ƒ˜ EVALUTION OF PREFIX EXPRESSION ๏ƒ˜ RECURSION APPLICATION OF STACK
  • 9. It is the method of writing operation of an expression neither before there operants or after them is called polish notation. There are 3 types of polish notation: i)Infix notation eg : A+B ii)Prefix notation eg : +AB iii)Postfix notation eg : AB+ POLISH NOTATION
  • 10. 1) The order in which the operators appear is not reversed. 2) When the '+' is read, it has lower precedence than the '*', so the '*' must be printed first. 3) We will show this in a table with three columns. The first will show the symbol currently being read. 4) The second will show what is on the stack and the third will show the current contents ALGORITHM : INFIX TO POSTFIX CONVERSION
  • 11. CONVERSION OF INFIX TO POSTFIX EXPRESSION
  • 12. EXPRESSION : 1,2,3,*,+,4,- FINAL ANSWER IS 3. EVALUTION OF POSTFIX EXPRESSION
  • 13. 1) Push โ€œ)โ€ onto STACK, and add โ€œ(โ€œ to end of the A. 2) Scan A from right to left and repeat step 3 to 6 for each element of A until the STACK is empty. 3) If an operand is encountered add it to B. 4) If a right parenthesis is encountered push it onto STACK ALGORITHM : INFIX TO PREFIX EXPRESSION
  • 14. CONVERSION OF INFIX TO PREFIX EXPRESSION
  • 15. EXPRESSION : +,-,2,7,*,8,/,4,12 FINAL ANSWER IS 29 EVALUTION OF PREFIX EXPRESSION
  • 16. Recursion is an approach in which a function calls itself with an argument. Upon reaching a termination condition, the control returns to the calling function. RECURSION