Trees-traversals of trees and reviewing stacks


The purpose of this assignment is to familiarize you with trees and traversals of trees, as well as to review stacks. In this assignment you will have to implement a program that reads a series of numbers and operations from a file using in-order traversal, build a tree from the file data, and evaluate the data in post-order by traversing the tree while modifying a stack.

Your stack must use a linked list to store the data – not an array.

Begin by defining your tree structure(s).

• Read in a mathematical equation from a file using pre-order traversal to build your tree.
• Use the @ symbol to denote a NULL as we have done in the code.
• When your tree is complete, initialize your stack as empty.
• Now perform a post-order traversal on your tree.
• If the node contains a number, push it onto your stack.
• If the node contains an operator (we’ll stick to just + - * / ), pop the top two numbers off your stack, perform said operation on them, and push the result back on your stack.
• When you finish traversing your tree, you should have the answer to your mathematical equation.

Make sure your code is humanly readable! Use meaningful variable names, clearly document the purpose of variables and code.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Trees-traversals of trees and reviewing stacks
Reference No:- TGS0395

Expected delivery within 24 Hours