08/06/12 06:56:07
>>60 もとい、前レスの修正、且つソース有り。以上
- I (1)+ V (2)
| | - P (3)+ Q (4)+ R (5)+ S (6)
| | | - N (4)+ O (5)
| | | | - L (5)+ M (6)
| - H (2)
| | - A (3)+ E (4)
| | | | - C (5)
int depth = 1;
//--- nodeを根とする部分木のノードをTREE表示 ---//
private void printSubTree(Node node) {
if (node == null) return;
if (depth == 1) System.out.print("-");
System.out.print( " " + node.key + " " + "(" + depth + ")" );
if (node.right != null) {
System.out.print("+");
depth++;
printSubTree(node.right);
depth--;
} else
System.out.println();
if (node.left != null) {
for(byte a=0; a<depth; a++) System.out.print("| ");
System.out.print("-");
depth++;
printSubTree(node.left);
depth--;
}
}