📄 generaltree.java
字号:
public class GeneralTree
{
/**
* the root of GeneralTree.
*/
private GTNode root;
/**
* constructor of GeneralTree,with a null root.
*/
public GeneralTree(){
root=null;
}
/**
* constructor of GeneralTree,with a root which item is obj.
*/
public GeneralTree(Object obj){
root=new GTNode(obj);
}
/**
* remove all node of this tree.
*/
public void clear(){
root=null;
}
/**
* return the root of this tree.
*/
public GTNode root(){
return root;
}
/*******************fill your code in the following functions.************************/
/**
* vist this tree in postorder.
*/
public void visitPostorder(){
//fill your code here.
}
/**
* test code for GTNode.
*/
public static void main(String[] args)
{
System.out.println("=====test your General tree.====");
GeneralTree tree=new GeneralTree("A");
//用GTNode 中的方法实现如图所示(左边)的general tree。
System.out.println("your tree should be : E F G B H I C J K L D A ");
tree.visitPostorder();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -