Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Added Infix to Postfix Conversion in Python #235

Merged
merged 3 commits into from
Sep 3, 2020

Conversation

nutanaarohi123
Copy link
Contributor

@nutanaarohi123 nutanaarohi123 commented Aug 31, 2020

Infix expression is converted to postfix conversion using Stack and evaluated in Left to Right order.
It makes the code more efficient and even reduces the time complexity.

Have Read the contributing guidelines ?
YES

Issue No.
#91 (Issue no. 1 )

@@ -0,0 +1,12 @@
#In Infix expression operator is in between every pair of operands.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the README to this ⬇

### Infix to Postfix

> • In Infix expression operator is in between every pair of operands.<br>
> • In Postfix expression, the operator is followed for every pair of operands. 

- Infix expression is converted to postfix conversion using Stack.
- Postfix expression is evaluated using Stack in Left to Right order.

##### If the scanned character is operand, show it as output. Else, If precedence of scanned operator is greater than the precedence of the operator in the stack,push it.

> Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the scanned operator.

•  If the scanned input is '(', push it into stack<br>
• If the scanned input is ')' ,pop the stack and the output it until '(' comes.<br>
• Repeat above steps. Continue Pop and output from stack until it becomes empty.

##### It makes the code more efficient and even reduces the time complexity. 

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just replace the above text with the present one.

# Displaying the Output
print("Postfix expression: ", infix_to_postfix(infix_expression))

"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this part in README under Constraints

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated changes. Kindly review.

Copy link

@Neilblaze Neilblaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @nutanaarohi123 ! 🎉

  • Nice & Clean code 😄

@powerexploit
Copy link
Owner

Awesome work @nutanaarohi123 !

  • Nice & Clean code smile

Nice @nutanaarohi123

@powerexploit powerexploit merged commit 941f380 into powerexploit:master Sep 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants