My solution for the assignment is attached at the bottom. For this post, I wanted to provide a detailed illustration of how I tackle recursive problems with list_longest_path as example. Due to time issues (on my part), I will "draw" my logic rather than providing a good written explanation.
I ended up writing a bit more than I originally planned, but anyhow, hope it helps.
I particularly like the implementation where None is taken as a base case. Its conceptually simpler I think. It's kind of like saying min([...] +[0]), which says what are the minimum value in list X; if this value is negative, return 0. Anyhow, these tree exercise and assignment 2 I think has provided me some insight into what it means to be "recursible"... I hope to address this in next week's post (unfortunately this week I must finish writing about ADT... and I'm a little busy now).
No comments:
Post a Comment