Binary trees are in a weird spot for me. I understand them very well, but I do not understand exercise 3, part b.
It asks me to find the deepest leaf in a series of binary trees, and I really just do not understand. I can find the length of the tree leaves all the way to the right, and all the way to the left, but nothing else. I just don't understand how to manipulate the code to check every single possible branch.
I understood part A though, where it asks me to make a tree from an inorder and pre order list representation. It requires both logic and the ability to understand code written backwards. I basically separated the code into the categories of right side in order, right side pre order, left side in order, and right side pre order. It ended up being fairly simple, and of course required recursion.
No comments:
Post a Comment