Friday 25 October 2013

Trees, Binary, Tuples. - Week 4

    Binary trees are very interesting with all their applications, like the ability to use nodes in a queue and such. The exercise was quite straight forward, with the exception of part b in which I kept getting lists within my node lists but a simple list comprehension solved my problem. I managed to solve the exercise without helper functions thanks to tuples, something that I was introduced to this year as I had programmed in java. The usefulness of tuples has actually become very apparent now, it really simplifies things when I can return a small tuple.

2 comments:

  1. Couldn't, in Java, you just use arrays instead of a helper function as well?

    ReplyDelete
    Replies
    1. Yes you're right, but I think tuples are more memory efficient than arrays.

      Delete