affiliate marketing
Showing posts with label CONVERSION OF INFIX EXPRESSION TO POSTFIX coding. Show all posts
Showing posts with label CONVERSION OF INFIX EXPRESSION TO POSTFIX coding. Show all posts

Monday, 12 December 2011

CONVERSION OF INFIX EXPRESSION TO POSTFIX


CONVERSION OF INFIX EXPRESSION TO POSTFIX
Aim
To write a C-program to convert the given infix expression to its postfix format.

Algorithm

STEP 1: Start
STEP 2: Initialize the stack.
STEP 3: While (INSTR!= NULL)
STEP 4: CH= get the character from INSTR.
STEP 5: If( CH= = operand) then
               append CH int POSTSTR
               else if(CH = = ‘(‘) then
               push CH into stack
               else if(CH = =’)’) then
               pop the data from the stack and append the data into POSTSTR until we get                         
               ‘(‘ from the stack
               else
               while(precedence (TOP) >= precedence (CH))
               pop the data from stack and append the data into POSTSTR.
               [End of while structure]
               [End of if structure]

STEP 6: Push CH into the stack.
STEP 7: [End of second while structure]
STEP 8: pop all the data from stack and append data into POSTSTR.
STEP 9: Stop
Coding: