Copyright ©
2005 Suradet Jitprapaikulsarn
สงวนลิขสิทธิ์ 2548 สุรเดช จิตประไพกุลศาล
Homework 7 (Due 8 August 2005)
- Write a function, height, to determine the height of a binary tree.
- Write a function, maximum, to determine the maximum value in a binary tree of numbers. Be careful about an empty tree.
- Write a function, BST?, to determine whether a binary tree is a binary search tree (BST). A BST is a binary tree with the following properties:
- For each node in a BST:
- all the values in the left subtree are less than the value in the node.
- all the values in the right subtree are more than the value in the node.
- (Bonus) Write a function, longestDistance,
to determine the longest distance between two nodes in a binary tree.
Note that the longest path does not need to include the root of
the tree.