SlideShare a Scribd company logo
STACK
STACK
 The stack data structure is a linear data structure
that accompanies a principle known as LIFO (Last In
First Out) or FILO (First In Last Out).
 Real-life examples of a stack are a deck of cards, piles
of books, piles of money, and many more.
STACK
 This example allows you to perform operations from
one end only, like when you insert and remove new
books from the top of the stack. It means insertion and
deletion in the stack data structure can be done only
from the top of the stack. You can access only the top
of the stack at any given point in time.
 Inserting a new element in the stack is termed a push
operation.
 Removing or deleting elements from the stack is termed
pop operation.
STACK REPRESENTATION
WORKING OF STACK
 Now, assume that you have a stack of books.
 You can only see the top, i.e., the top-most book,
namely 40, which is kept top of the stack.
 If you want to insert a new book first, namely 50,
you must update the top and then insert a new
text.
 And if you want to access any other book other
than the topmost book that is 40, you first
remove the topmost book from the stack, and
then the top will point to the next topmost book
WORKING OF STACK
 After working on the representation of stacks in
data structures, you will see some basic
operations performed on the stacks in data
structures.
WORKING OF STACK
BASIC OPERATIONS ON
STACK:PUSH
 Push Operation
 Push operation involves inserting new elements in
the stack. Since you have only one end to insert a
unique element on top of the stack, it inserts the new
element at the top of the stack.
BASIC OPERATIONS ON
STACK:PUSH
 Push operation includes various steps, which are
as follows :
 Step 1: First, check whether or not the stack is
full
 Step 2: If the stack is complete, then exit
 Step 3: If not, increment the top by one
 Step 4: Insert a new element where the top is
pointing
 Step 5: Success
BASIC OPERATIONS ON
STACK:PUSH
 begin
 if top = n then stack full
 top = top + 1
 stack (top) : = item;
 end
BASIC OPERATIONS ON STACK:POP
 Pop Operation
 Pop operation refers to removing the element from
the stack again since you have only one end to do all
top of the stack. So removing an element from the top
of the stack is termed pop operation.
BASIC OPERATIONS ON STACK:POP
 Step 1: First, check whether or not the stack is
empty
 Step 2: If the stack is empty, then exit
 Step 3: If not, access the topmost data element
 Step 4: Decrement the top by one
 Step 5: Success
BASIC OPERATIONS ON STACK:POP
 begin
 if top = 0 then stack empty;
 item := stack(top);
 top = top - 1;
 end;
BASIC OPERATIONS ON
STACK:PEEK
 Peek Operation
 Peek operation refers to retrieving the topmost
element in the stack without removing it from the
collections of data elements.
Begin
if top = -1 then stack empty
item = stack[top]
return item
End
BASIC OPERATIONS ON
STACK:ISFULL()
 isFull()
 isFull function is used to check whether or not a
stack is empty.
begin
if
top equals to maxsize
return true
else
return false
else if
end
BASIC OPERATIONS ON
STACK:ISEMPTY
 isEmpty()
 Empty function is used to check whether or not a
stack is empty.
begin
if
top less than 1
return true
else
return false
else if
end
IMPLEMENTATION OF STACK
 You can perform the implementation of stacks in
data structures using two data structures that
are an array and a linked list.
1. Array: In array implementation, the stack is
formed using an array. All the operations are
performed using arrays. You will see how all
operations can be implemented on the stack in
data structures using an arraydata structure.
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
USING ARRAY
IMPLEMENTATION OF STACK
2. Linked-List: Every new element is inserted as a
top element in the linked list implementation of
stacks in data structures. That means every
newly inserted element is pointed to the top.
Whenever you want to remove an element from
the stack, remove the node indicated by the top,
by moving the top to its previous node in the
list.
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
 isEmpty function is used to check whether or not a stack
is empty.
int isEmpty()
{
if(top==NULL)
return 1;
else
return 0;
}
IMPLEMENTATION OF STACK
USING LINKED LIST
Peek operation refers to retrieving the topmost element
in the stack without removing it from the collections of
data elements.
int peek()
{
if(isEmpty())
{
printf("Stack underflow...");
exit(1);
}
return top->data;
}
IMPLEMENTATION OF STACK
USING LINKED LIST
 In linked list implementation of stack, the
nodes are maintained non-contiguously in the
memory. Each node contains a pointer
to its immediate successor node in the stack. Stack
is said to be overflown if the space left in the
memory heap is not enough to create a node.
 The top most node in the stack always contains
null in its address field. Lets discuss the way in
which, each operation is performed in linked list
implementation of stack.
IMPLEMENTATION OF STACK
USING LINKED LIST
Adding a node to the stack (Push operation)
Adding a node to the stack is referred to
as push operation. Pushing an element to a stack
in linked list implementation is different from that
of an array implementation. In order to push an
element onto the stack, the following steps are
involved.
IMPLEMENTATION OF STACK
USING LINKED LIST
1. Create a node first and allocate memory to it.
2. If the list is empty then the item is to be pushed
as the start node of the list. This includes
assigning value to the data part of the node and
assign null to the address part of the node.
3. If there are some nodes in the list already, then
we have to add the new element in the beginning
of the list (to not violate the property of the stack).
For this purpose, assign the address of the
starting element to the address field of the new
node and make the new node, the starting node of
the list.
Time Complexity : o(1)
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
Deleting a node from the stack (POP
operation)
Deleting a node from the top of stack is referred
to as pop operation. Deleting a node from the
linked list implementation of stack is different
from that in the array implementation. In order to
pop an element from the stack, we need to follow
the following steps :
IMPLEMENTATION OF STACK
USING LINKED LIST
Deleting a node from the stack (POP
operation)
 Check for the underflow condition: The underflow
condition occurs when we try to pop from an already
empty stack. The stack will be empty if the head
pointer of the list points to null.
 Adjust the head pointer accordingly: In stack, the
elements are popped only from one end, therefore, the
value stored in the head pointer must be deleted and
the node must be freed. The next node of the head node
now becomes the head node.
Time Complexity : o(n)
IMPLEMENTATION OF STACK
USING LINKED LIST
Display the nodes (Traversing)
Displaying all the nodes of a stack needs
traversing all the nodes of the linked list organized
in the form of stack. For this purpose, we need to
follow the following steps.
 Copy the head pointer into a temporary pointer.
 Move the temporary pointer through all the nodes of
the list and print the value field attached to every
node.
Time Complexity : o(n)
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
IMPLEMENTATION OF STACK
USING LINKED LIST
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
 A stack is a very effective data structure for
evaluating arithmetic expressions in
programming languages. An arithmetic
expression consists of operands and operators.
 In addition to operands and operators, the
arithmetic expression may also include
parenthesis like "left parenthesis" and "right
parenthesis".
Example: A + (B - C)
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
 To evaluate the expressions, one needs to be
aware of the standard precedence rules for
arithmetic expression. The precedence rules for
the five basic arithmetic operators are:
Operators Associativity Precedence
^ exponentiation Right to left Highest followed by
*Multiplication and
/division
*Multiplication,
/division
Left to right Highest followed by +
addition and -
subtraction
+ addition, -
subtraction
Left to right lowest
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Evaluation of Arithmetic Expression requires two
steps:
First, convert the given expression into special
notation.
Evaluate the expression in this new notation.
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Notations for Arithmetic Expression
There are three notations to represent an
arithmetic expression:
Infix Notation
Prefix Notation
Postfix Notation
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Infix Notation
The infix notation is a convenient way of writing
an expression in which each operator is placed
between the operands. Infix expressions can be
parenthesized or unparenthesized depending upon
the problem requirement.
Example: A + B, (C - D) etc.
All these expressions are in infix notation because
the operator comes between the operands.
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Prefix Notation
The prefix notation places the operator before the
operands. This notation was introduced by the
Polish mathematician and hence often referred to
as polish notation.
Example: + A B, -CD etc.
All these expressions are in prefix notation
because the operator comes before the operands.
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Postfix Notation
The postfix notation places the operator after the
operands. This notation is just the reverse of Polish
notation and also known as Reverse Polish
notation.
Example: AB +, CD+, etc.
STACK APPLICATION-ARITHMETIC
EXPRESSION EVALUATION
Conversion of Arithmetic Expression into
various Notations:
Infix Notation Prefix Notation Postfix Notation
A * B * A B AB*
(A+B)/C /+ ABC AB+C/
(A*B) + (D-C) +*AB - DC AB*DC-+
ALGORITHM TO CONVERT INFIX TO
POSTFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
POSTFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
POSTFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
POSTFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
PREFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
PREFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
PREFIX EXPRESSION
ALGORITHM TO CONVERT INFIX TO
PREFIX EXPRESSION

More Related Content

Similar to Stack data structures with definition and code (20)

PPTX
Stacks in c++
Vineeta Garg
 
PPTX
Stack in Sata Structure
Muhazzab Chouhadry
 
PDF
Chapter 4 stack
jadhav_priti
 
PDF
04 stacks
Rajan Gautam
 
PDF
Chapter 5 Stack and Queue.pdf
GirT2
 
PDF
Stack
maamir farooq
 
PDF
Stack
Amrutha Rajan
 
PPTX
Stack.pptx
AliRaza899305
 
PPTX
Stack data structure
rogineojerio020496
 
PPTX
c programming and data structure notes for ECE
ShaMaa11
 
PPT
Stacks
sweta dargad
 
PPTX
stacks and queues
EktaVaswani2
 
PPTX
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
PPTX
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
sunitha1792
 
PPTX
Stack in C.pptx
RituSarkar7
 
PPTX
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
emathemathematics
 
PDF
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
PDF
Data structure.pdf
piyushagarwal279293
 
PPTX
Stacks and queues using aaray line .pptx
ramkumar649780
 
PDF
Stacks
Shivam Singh
 
Stacks in c++
Vineeta Garg
 
Stack in Sata Structure
Muhazzab Chouhadry
 
Chapter 4 stack
jadhav_priti
 
04 stacks
Rajan Gautam
 
Chapter 5 Stack and Queue.pdf
GirT2
 
Stack.pptx
AliRaza899305
 
Stack data structure
rogineojerio020496
 
c programming and data structure notes for ECE
ShaMaa11
 
Stacks
sweta dargad
 
stacks and queues
EktaVaswani2
 
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
sunitha1792
 
Stack in C.pptx
RituSarkar7
 
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
emathemathematics
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
Data structure.pdf
piyushagarwal279293
 
Stacks and queues using aaray line .pptx
ramkumar649780
 
Stacks
Shivam Singh
 

Recently uploaded (20)

PPTX
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
PPTX
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PDF
InformaticsPractices-MS - Google Docs.pdf
seshuashwin0829
 
PPTX
How to Add Columns and Rows in an R Data Frame
subhashenia
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
thid ppt defines the ich guridlens and gives the information about the ICH gu...
shaistabegum14
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
InformaticsPractices-MS - Google Docs.pdf
seshuashwin0829
 
How to Add Columns and Rows in an R Data Frame
subhashenia
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
What Is Data Integration and Transformation?
subhashenia
 
Research Methodology Overview Introduction
ayeshagul29594
 
Ad

Stack data structures with definition and code

  • 2. STACK  The stack data structure is a linear data structure that accompanies a principle known as LIFO (Last In First Out) or FILO (First In Last Out).  Real-life examples of a stack are a deck of cards, piles of books, piles of money, and many more.
  • 3. STACK  This example allows you to perform operations from one end only, like when you insert and remove new books from the top of the stack. It means insertion and deletion in the stack data structure can be done only from the top of the stack. You can access only the top of the stack at any given point in time.  Inserting a new element in the stack is termed a push operation.  Removing or deleting elements from the stack is termed pop operation.
  • 5. WORKING OF STACK  Now, assume that you have a stack of books.  You can only see the top, i.e., the top-most book, namely 40, which is kept top of the stack.  If you want to insert a new book first, namely 50, you must update the top and then insert a new text.  And if you want to access any other book other than the topmost book that is 40, you first remove the topmost book from the stack, and then the top will point to the next topmost book
  • 6. WORKING OF STACK  After working on the representation of stacks in data structures, you will see some basic operations performed on the stacks in data structures.
  • 8. BASIC OPERATIONS ON STACK:PUSH  Push Operation  Push operation involves inserting new elements in the stack. Since you have only one end to insert a unique element on top of the stack, it inserts the new element at the top of the stack.
  • 9. BASIC OPERATIONS ON STACK:PUSH  Push operation includes various steps, which are as follows :  Step 1: First, check whether or not the stack is full  Step 2: If the stack is complete, then exit  Step 3: If not, increment the top by one  Step 4: Insert a new element where the top is pointing  Step 5: Success
  • 10. BASIC OPERATIONS ON STACK:PUSH  begin  if top = n then stack full  top = top + 1  stack (top) : = item;  end
  • 11. BASIC OPERATIONS ON STACK:POP  Pop Operation  Pop operation refers to removing the element from the stack again since you have only one end to do all top of the stack. So removing an element from the top of the stack is termed pop operation.
  • 12. BASIC OPERATIONS ON STACK:POP  Step 1: First, check whether or not the stack is empty  Step 2: If the stack is empty, then exit  Step 3: If not, access the topmost data element  Step 4: Decrement the top by one  Step 5: Success
  • 13. BASIC OPERATIONS ON STACK:POP  begin  if top = 0 then stack empty;  item := stack(top);  top = top - 1;  end;
  • 14. BASIC OPERATIONS ON STACK:PEEK  Peek Operation  Peek operation refers to retrieving the topmost element in the stack without removing it from the collections of data elements. Begin if top = -1 then stack empty item = stack[top] return item End
  • 15. BASIC OPERATIONS ON STACK:ISFULL()  isFull()  isFull function is used to check whether or not a stack is empty. begin if top equals to maxsize return true else return false else if end
  • 16. BASIC OPERATIONS ON STACK:ISEMPTY  isEmpty()  Empty function is used to check whether or not a stack is empty. begin if top less than 1 return true else return false else if end
  • 17. IMPLEMENTATION OF STACK  You can perform the implementation of stacks in data structures using two data structures that are an array and a linked list. 1. Array: In array implementation, the stack is formed using an array. All the operations are performed using arrays. You will see how all operations can be implemented on the stack in data structures using an arraydata structure.
  • 27. IMPLEMENTATION OF STACK 2. Linked-List: Every new element is inserted as a top element in the linked list implementation of stacks in data structures. That means every newly inserted element is pointed to the top. Whenever you want to remove an element from the stack, remove the node indicated by the top, by moving the top to its previous node in the list.
  • 29. IMPLEMENTATION OF STACK USING LINKED LIST  isEmpty function is used to check whether or not a stack is empty. int isEmpty() { if(top==NULL) return 1; else return 0; }
  • 30. IMPLEMENTATION OF STACK USING LINKED LIST Peek operation refers to retrieving the topmost element in the stack without removing it from the collections of data elements. int peek() { if(isEmpty()) { printf("Stack underflow..."); exit(1); } return top->data; }
  • 31. IMPLEMENTATION OF STACK USING LINKED LIST  In linked list implementation of stack, the nodes are maintained non-contiguously in the memory. Each node contains a pointer to its immediate successor node in the stack. Stack is said to be overflown if the space left in the memory heap is not enough to create a node.  The top most node in the stack always contains null in its address field. Lets discuss the way in which, each operation is performed in linked list implementation of stack.
  • 32. IMPLEMENTATION OF STACK USING LINKED LIST Adding a node to the stack (Push operation) Adding a node to the stack is referred to as push operation. Pushing an element to a stack in linked list implementation is different from that of an array implementation. In order to push an element onto the stack, the following steps are involved.
  • 33. IMPLEMENTATION OF STACK USING LINKED LIST 1. Create a node first and allocate memory to it. 2. If the list is empty then the item is to be pushed as the start node of the list. This includes assigning value to the data part of the node and assign null to the address part of the node. 3. If there are some nodes in the list already, then we have to add the new element in the beginning of the list (to not violate the property of the stack). For this purpose, assign the address of the starting element to the address field of the new node and make the new node, the starting node of the list. Time Complexity : o(1)
  • 35. IMPLEMENTATION OF STACK USING LINKED LIST Deleting a node from the stack (POP operation) Deleting a node from the top of stack is referred to as pop operation. Deleting a node from the linked list implementation of stack is different from that in the array implementation. In order to pop an element from the stack, we need to follow the following steps :
  • 36. IMPLEMENTATION OF STACK USING LINKED LIST Deleting a node from the stack (POP operation)  Check for the underflow condition: The underflow condition occurs when we try to pop from an already empty stack. The stack will be empty if the head pointer of the list points to null.  Adjust the head pointer accordingly: In stack, the elements are popped only from one end, therefore, the value stored in the head pointer must be deleted and the node must be freed. The next node of the head node now becomes the head node. Time Complexity : o(n)
  • 37. IMPLEMENTATION OF STACK USING LINKED LIST Display the nodes (Traversing) Displaying all the nodes of a stack needs traversing all the nodes of the linked list organized in the form of stack. For this purpose, we need to follow the following steps.  Copy the head pointer into a temporary pointer.  Move the temporary pointer through all the nodes of the list and print the value field attached to every node. Time Complexity : o(n)
  • 46. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION  A stack is a very effective data structure for evaluating arithmetic expressions in programming languages. An arithmetic expression consists of operands and operators.  In addition to operands and operators, the arithmetic expression may also include parenthesis like "left parenthesis" and "right parenthesis". Example: A + (B - C)
  • 47. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION  To evaluate the expressions, one needs to be aware of the standard precedence rules for arithmetic expression. The precedence rules for the five basic arithmetic operators are: Operators Associativity Precedence ^ exponentiation Right to left Highest followed by *Multiplication and /division *Multiplication, /division Left to right Highest followed by + addition and - subtraction + addition, - subtraction Left to right lowest
  • 48. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Evaluation of Arithmetic Expression requires two steps: First, convert the given expression into special notation. Evaluate the expression in this new notation.
  • 49. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Notations for Arithmetic Expression There are three notations to represent an arithmetic expression: Infix Notation Prefix Notation Postfix Notation
  • 50. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Infix Notation The infix notation is a convenient way of writing an expression in which each operator is placed between the operands. Infix expressions can be parenthesized or unparenthesized depending upon the problem requirement. Example: A + B, (C - D) etc. All these expressions are in infix notation because the operator comes between the operands.
  • 51. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Prefix Notation The prefix notation places the operator before the operands. This notation was introduced by the Polish mathematician and hence often referred to as polish notation. Example: + A B, -CD etc. All these expressions are in prefix notation because the operator comes before the operands.
  • 52. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Postfix Notation The postfix notation places the operator after the operands. This notation is just the reverse of Polish notation and also known as Reverse Polish notation. Example: AB +, CD+, etc.
  • 53. STACK APPLICATION-ARITHMETIC EXPRESSION EVALUATION Conversion of Arithmetic Expression into various Notations: Infix Notation Prefix Notation Postfix Notation A * B * A B AB* (A+B)/C /+ ABC AB+C/ (A*B) + (D-C) +*AB - DC AB*DC-+
  • 54. ALGORITHM TO CONVERT INFIX TO POSTFIX EXPRESSION
  • 55. ALGORITHM TO CONVERT INFIX TO POSTFIX EXPRESSION
  • 56. ALGORITHM TO CONVERT INFIX TO POSTFIX EXPRESSION
  • 57. ALGORITHM TO CONVERT INFIX TO POSTFIX EXPRESSION
  • 58. ALGORITHM TO CONVERT INFIX TO PREFIX EXPRESSION
  • 59. ALGORITHM TO CONVERT INFIX TO PREFIX EXPRESSION
  • 60. ALGORITHM TO CONVERT INFIX TO PREFIX EXPRESSION
  • 61. ALGORITHM TO CONVERT INFIX TO PREFIX EXPRESSION