|COMP1011 Exercises for Week 12|
|Computing 1A 05s2||
Tue 19 Jul 2005 14:37
depthTree :: Tree a -> Int
which computes the depth of a tree. For example, we have
Tree> depthTree Leaf 0 Tree> depthTree (Node 1 Leaf Leaf ) 1 Tree> depthTree (Node 2 Leaf (Node 3 Leaf Leaf)) 2
When you have completed the above exercises show them to your tutor for this week's core mark.
Implement a function reverseTree:: Tree a -> Tree a which reverses the order of the elements in the tree by swaping the left and the right subtree of each node.
4 4 / \ / \ 2 6 ===> 6 2 / / \ / \ \ 1 5 7 7 5 1
When you have completed the above exercises show them to your tutor for this week's advanced mark.