Java Code: 1) write three routines, pre-order, in-order, and post-order which wi
ID: 3665064 • Letter: J
Question
Java Code: 1) write three routines, pre-order, in-order, and post-order which will print the tree in each of those ways, similar to what the toString method does. 2) write a recursive routind depth() which returns the depth of the deepest node in the tree. The root has depth 0. The empty tree has depth --1. 3) Write a main program that asks the user to enter two integers: n, a number of nodes, and howMany. Over and over again, for a total of howMany times, instantiate a new tree with n nodes, find its depth, and ultimately print the depths of the shallowest, average depth, and deepest tree. Sample run: Enter n: 10 Emter repetitions: 1000 Shallowest tree was <something around 3> Deepest tree was <something around 9> Average depth was <something>
Explanation / Answer
Inorder
}
Post Order
}
Pre Order
/**Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.