This week we get to practice with more trees, we learned about Binary Trees and practice recursions.
The worst thing is that the I find recursions so difficult. I mean, during the lab, it took me over an hour to implement list_longest_path. I think the problem is that I have not gotten the hang of it, because I notice other students and they seems to be fine, it is simply a question of experience. I find it hard to keep track of what is going on in the recursive process so I don't know whether I am doing things correctly. The funny thing I notice however, is that usually, the way we expect the recursive code to look is exactly what we want to have to implement it. for example, with list longest path, i had to recursive keep track of the longest path, and so i put list longest path' inside 'list longest path', and it seemed like all I had to do was 'assume' list longest path would spit out what is wanted (the longest path for tree rooted at root), and just use the return value to compare with what I have so far in a separate list and return the longest path from this list, and so on, recursively. By implementing the overall functions in such a way it seems to work, hooray!
No comments:
Post a Comment