Write the following Member Functions for a Binary Search Tree Class for Tree holding Integer Objects
Given :
private TreeNode root; // in Tree Class
The following methods that are private methods are helper methods called by a public method from within a class that has the private data value root (so we can pass parameter). The public methods may directly access the root.
public void insert(int n)
private void printInOrder(TreeNode curr) // originally receives the root
private void printReverseOrder(TreeNode curr)
private void printPreOrder(TreeNode curr)
private void printPostOrder(TreeNode curr)
public void fill(int n) // fills tree with n random numbers
private boolean isThere(TreeNode curr, int n) // return true if # in tree
private int ctNodes(TreeNode curr)
private int ctLeafs(TreeNode curr)
private int ctNonLeafs(TreeNode curr)
private TreeNode location(TreeNode curr, int n) // return null if not there
private int height(TreeNode curr)
private int smallest(TreeNode curr)
public double average()
private int ctNodeswith2kids(TreeNode curr)
private int ctOddNums(TreeNode curr)
private void changeEven(TreeNode curr) // change any even number to next odd number
private void printOnlyEvenNumbers(TreeNode curr)
private int sumOfLeafs(TreeNode curr)
private void createTwins(TreeNode curr) // any node that has only 1 child - create twin for it
private void printAncestors(TreeNode curr, String st)
print ancestors of st. You may assume she is in the tree. Do it recursively and non-recursively. (Not hard - draw the picture)