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

Stacks

  • 1.
  • 2.
     INTRODUCTION  HISTORY STACK  PUSH , POP  APPLICATION OF STACK CONTENTS
  • 3.
    A Stack isdata 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 thecomputer 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 : Stackis 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 afunction 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 afunction 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 ALIST.  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 themethod 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 orderin 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 INFIXTO POSTFIX EXPRESSION
  • 12.
    EXPRESSION : 1,2,3,*,+,4,- FINALANSWER 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 INFIXTO PREFIX EXPRESSION
  • 15.
    EXPRESSION : +,-,2,7,*,8,/,4,12 FINALANSWER IS 29 EVALUTION OF PREFIX EXPRESSION
  • 16.
    Recursion is anapproach in which a function calls itself with an argument. Upon reaching a termination condition, the control returns to the calling function. RECURSION