Implement the pre-order tree traversal algorithm in C++. This program should use the following binary tree (see image) and display the pre-order tree traversal of the nodes’ values. Feel free to write this iteratively or recursively.
Also, explain how it works and how a new tree could be provided to the code.
PS: make sure that the logic of the program is correct, meaning that it can work well with different binary trees. I would like to change the tree input to the pre-order traversal function. The program should work errorless and display the result correctly. No need to code it to read the user input, however, provide instructions on how a new tree can be defined in this program to check if the program works fine with different trees.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here