Professor Heap gave the following hint for exercise 4, part b:
"Assigning a depth of -1 to empty trees should simplify your code—you should be able to treat this case more uniformly."
I managed to solve this exercise without much difficulty and in writing the function, nowhere did I see the need to assign a depth of -1 to empty trees. Defining the depth of an empty tree to be 0 seems much more natural to me and my code was quite simple—only around 6 lines. I was curious if any other students incorporated this hint into their code and found it useful. If so, how did it simplify your code? Perhaps the hint made more sense for certain approaches to the function than to others.
No comments:
Post a Comment