Problem 1: Induction Proof
Is one node a perfect binary tree? Yes. 1 node. Is it odd? Yes.
Assume this holds true for values k = 1 to N.
You need to add a full row of nodes at the bottom. So we need to add twice the number of elements, an even number.
So you’d have an odd number plus an even number; an
a. Binary search, searching a well balanced binary tree b. … c. Popping from a stack, assigning to head in LinkedList d. Towers of Hanoi and Fibonnaci recursively
Given postorder traversal or tree and inorder traversal, uniquely reconstruct the tree.
- Root has to be the
- Locate that node in the inorder traversal and realize that all nodes to the left are on the left side of the tree. Same for those on the right.
- Look at the postorder for those on the left and you can find the root
- Do the same for the right
Pretty much 100% correct. Didn’t really need to check if both left and right are null, can leave that out.