This repository contains the Java code for a program that constructs a binary expression tree from a user-input arithmetic expression. The program validates the expression, displays the resulting tree in different traversal orders, and computes the expression's result using the binary tree.
The program offers the following options in a menu:
- Input arithmetic expression (infix notation): The user enters an expression in infix notation. The expression is validated, and a message is displayed indicating whether it is valid or invalid.
- Create binary expression tree: The entered infix expression is converted into a binary expression tree.
- Display binary expression tree: The tree is displayed in three different traversals:
- Pre-order
- In-order
- Post-order
- Calculate expression: The tree is traversed to compute the expression. The result is displayed on the screen.
- Exit the program: Ends the program execution.
- The expression must contain only integers and/or decimal numbers, parentheses, and the following binary operators:
+
,-
,*
,/
. - Valid expressions will be processed, while invalid expressions will result in an error message.