()
| 51 | } |
| 52 | |
| 53 | public boolean isBST() { |
| 54 | if (left != null) { |
| 55 | if (data < left.data || !left.isBST()) { |
| 56 | return false; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (right != null) { |
| 61 | if (data >= right.data || !right.isBST()) { |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | public int height() { |
| 70 | int leftHeight = left != null ? left.height() : 0; |