class Node { int data; // このノードが保持するデータ Node left=null; // 左の部分木への参照 Node right=null; // 右の部分木への参照 /* 「left以下の任意のデータ<= data <=right以下の任意のデータ」 となるように,データを挿入する. */ public void insert (int data) { if (data < this.data) { // 左へ挿入 if (left == null) { left = new Node(); left.data = data; } else { left.insert(data); } } else { // 右へ挿入 if (right == null) { right = new Node(); right.data = data; } else { right.insert(data); } } } // 木の高さを計算 public int height () { int left_height=0, right_height=0; if (left != null) { left_height = left.height(); } if (right != null) { right_height = right.height(); } return Math.max(left_height, right_height)+1; } public void show (int depth) { if (right!=null) right.show(depth+1); for (int i=0; i