Sunday, 16 March 2014

Slog 7: TreeList

     I especially enjoyed exercise 3 this week. I had pulled up images of random trees trying to think up a solution to the task but came up empty for a while. Changing my approach I brought up microsoft paint and started drawing. After taking a few steps back and clearing my mind and remembering the absolutely helpful hint from lecture I had my algorithm going. That was for part A; now part B was a whole other beast. I wrote more versions of sum_to_deepest than I can count on my fingers. I followed the handout and wrote a fully functional method to determine the level of the deepest leaf in a given tree. However I couldn't find a use for that while summing. What I ended up doing was altering that method, and while adding up the levels, also sum the values and compare them at each junction. In the end, returning the sum that followed the level count worked for me.

No comments:

Post a Comment