Data structure and algorithms

profileSiper

This in java program


  

1. Implement a method of class MyTree that returns the height of the tree. The prototype of the method is given below.
 

Definition:
The height of a tree is defined as the length of the longest path from the root to one of the leaves.
The length of a path is defined as the number of edges.
As an example, if a tree has only the root, then the height of the tree is 0.

public int height (){

//return the height

}

Note: Like methods addNode, you may need to implement a private auxiliary method.

2. And test your program.

  • 9 years ago
  • 15
Answer(2)

Purchase the answer to view it

blurred-text
NOT RATED
  • attachment
    Tree.zip

Purchase the answer to view it

blurred-text
NOT RATED
  • attachment
    MyTree.java