This project implements an Infix to Postfix Expression Converter in Java. It takes a mathematical expression in infix notation (e.g., A + B * C
) and converts it into postfix notation (e.g., A B C * +
) using a stack-based approach.
- Tokenization: Splits the input expression into tokens (operands, operators, and parentheses).
- Operator Precedence Handling: Correctly handles operator precedence and associativity.
- Parentheses Support: Processes expressions with nested parentheses.
- Custom Stack Implementation: Uses a linked-list-based stack (
StackLL
) for flexibility.
src
: Contains the source code for the project.lib
: Contains any external dependencies (if applicable).bin
: Stores compiled output files (generated automatically).
- The input expression is tokenized using the
Token
class. - The
infixToPostfix
class processes the tokens using a stack to convert the expression to postfix notation. - The result is displayed as a postfix expression.
- Clone the repository.
- Open the project in your favorite Java IDE (e.g., VS Code).
- Run the
infixToPostfix
class with your input expression.
Input:
23 + 5 * ( 7 - 9 )
Output:
23 5 7 9 - * +
- Java Development Kit (JDK) 8 or higher.
Feel free to fork this repository and submit pull requests for improvements or bug fixes.
This project is open-source and available under the [MIT License](LICENSE).