Assignment 5

Consider the BTNode class:
class BTNode<T> {
    T data;
    BTNode<T> left, right;
    public BTNode(T data){ = data;
        left = null;
        right = null;
    public BTNode(T data, BTNode<T> left, BTNode<T> right){ = data;
        this.left = left;
        this.right = right;
Write each of the following functions on a binary tree with a given root of the type BTNode.
  1. Return the in-order traversal of a tree as a list.
  2. Test if a binary tree is symmetric (a binary tree is symmetric if rotating it about the vertical bar through the root for 180 degrees gives the same tree).
  3. Return the maximum path sum (the sum of the path from the root to a leaf is the sum of values in the nodes on the path).
  4. Test if a binary tree is a search tree.
  5. Test if a given value occurs in a binary search tree.
  6. Insert a value into a binary search tree such that the resulting tree remains a search tree.