Sunday, December 17, 2023

Infix to prefix conversion

 ALGORITHM:

STEP 1:

Add " ( " at the beginning of the infix expression and then reverse.

STEP 2:

Push " ) " on to the stack.

STEP 3:

Scan every character and repeat step 4 to step 7 until " ( " is encountered.

STEP 4:

If input is operand add in the output.

STEP 5:

If input is " ) " push into the stack.

STEP 6:

If input is "(" pop all the operators from the stack and add in the output one by one until ")" is popped.

STEP 7:

If input is operator pop all the stack which is higher precedence than input operator .Push input operator into the stack.

STEP 8:

Reverse the output


EXAMPLE:



No comments:

Post a Comment

Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, contact manager, note-taking, journal, and web browsing

 Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, conta...