Hi I'm looking for a bit of direction for solving a problem. Just a bit of back story, my professor gave us a project of Building a tree, and using it to evaluate a mathematical expression. As far as the assignment is concerned it was completed but I was looking to expand on it a bit. When we build the tree it is pretty much hard coded into the project; Building the nodes and then linking them together. I was wondering how could I do something like take the users input, parse it and then use that to build a tree.
So far I have tried: First removing all the white space from the users input. Taking the formatted input and breaking it into tokens. I then want to somehow be able to set it up so it follows order of operations. I read that order of operations is easy to implement if I were to convert the input to something called reverse polish notation. So I did some research and found an algorithm on wikipedia called the Shunting-yard algorithm. This will take infix notation and convert it to reverse polish notation. I stopped here because the algorithm uses stacks and such and I think using so kind of defeats the purpose of using the tree as in the spirit of the original assignment because I could just as easily use a stack and rpn to solve the math. I feel/think? it might be overkill to go to such lengths and then put it back in a tree. Once I get the data in whatever format how would I go about building the actual tree without hard coding it. I'm thinking the solution is probably going to be recursive, but I haven't found any information really how to do it.
So am I on the right track here? Or did I veer very far off? I would appreciate some tips and pointers to the right direction.