Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. public int depth() {
  2. if(leftDepth() > rightDepth()) {
  3. return leftDepth();
  4. } else {
  5. return rightDepth();
  6. }
  7. }
  8.  
  9. public int leftDepth() {
  10. if(getLeft() == null) {
  11. return 0;
  12. } else {
  13. return 1 + getLeft().depth();
  14. }
  15. }
  16.  
  17. public int rightDepth() {
  18. if(getRight() == null) {
  19. return 0;
  20. } else {
  21. return 1 + getRight().depth();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement