Wednesday, 9 March 2016

Week 8: Trees

Our skills from last weeks introduction are being put to the test with Trees! What better object to traverse recursively? They have an finite depth, but each tree has a different depth. Each tree node will have children nodes or none. The node will also have some value that we can modify. When writing methods and functions for trees, its the same thought process as recursion. The first case is considering a tree with one node, and the second is considering a node with children.

The in class example this week was writing a method that would evaluate a tree with the outside leaves being numbers and the inner nodes being operations. it was an interesting structure to draw out and then code for. I am starting to see how the trees will be used in assignment 2.

No comments:

Post a Comment