Question: Suppose you have some data keys sorted in an array and you want to construct a balanced binary search tree from them. Assume a tree
Suppose you have some data keys sorted in an array and you want to construct a balanced binary search tree from them. Assume a tree node representation TreeNode that includes instance variables key, left, and right.
Write pseudocode for an algorithm that constructs the tree and returns the root node. (If using Java don't worry about making the enclosing BinaryTreeclass instance.) You will need to use methods for making a new TreeNode, and for setting its left and right children.
What is the cost to construct the tree with justification. Compare this to the expected runtime of a Binary Search
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
