10000 Comparing mandliya:master...sastaachar:master · mandliya/algorithms_and_data_structures · GitHub
[go: up one dir, main page]

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mandliya/algorithms_and_data_structures
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: sastaachar/algorithms_and_data_structures
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Oct 9, 2019

  1. Added infix to postfix conversion

    Infix expression: The expression of the form a op b. When an operator is in-between every pair of operands.
    Postfix expression: The expression of the form a b op.  When an operator is followed for every pair of operands.
    
    Why postfix representation of the expression?
    The compiler scans the expression either from left to right or from right to left.
    
    Algorithm
    1. Scan the infix expression from left to right.
    2. If the scanned character is an operand, output it.
    3. Else,
    …..3.1 If the precedence of the scanned operator is greater than the precedence of the operator in the stack(or the stack is empty or the stack contains a ‘(‘ ), push it.
    …..3.2 Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the scanned operator. After doing that Push the scanned operator to the stack. (If you encounter parenthesis while popping then stop there and push the scanned operator in the stack.)
    4. If the scanned character is an ‘(‘, push it to the stack.
    5. If the scanned character is an ‘)’, pop the stack and and output it until a ‘(‘ is encountered, and discard both the parenthesis.
    6. Repeat steps 2-6 until infix expression is scanned.
    7. Print the output
    8. Pop and output from the stack until it is not empty.
    sastaachar authored Oct 9, 2019
    Configuration menu
    Copy the full SHA
    27a6cfd View commit details
    Browse the repository at this point in the history
Loading
0