public TSBNode searchValue(TSBNode node, string value) //返回查找到的结点 { TSBNode temp; if (node == null) { return(null); } else if (node.getValue() == value) { return(node); } else { temp = searchValue(node.getSonNode(), value); if (temp != null) { return(temp); } else { return(searchValue(node.getBroNode(), value)); } } }
public void displayTree(TSBNode node) { string sb, son; if (node != null) { if (node.getBroNode() == null) //判断该结点的兄弟结点是否为空,若为空则显示null,若不空则显示它的值 { sb = "Null"; } else { sb = node.getBroNode().getValue().ToString(); } if (node.getSonNode() == null) ////判断该结点的孩子结点是否为空,若为空则显示null,若不空则显示它的值 { son = "Null"; } else { son = node.getSonNode().getValue().ToString(); } mystr += node.getValue().ToString() + "\t\t\n" + son + "\t\t\t\n" + sb + "\r\n"; displayTree(node.getSonNode()); displayTree(node.getBroNode()); } }