gtnode.java
来自「java的二叉树的实现参考」· Java 代码 · 共 89 行
JAVA
89 行
/*请用BinaryNode 中的结构和方法实现该类。*/
public class GTNode extends BinaryNode
{
private GTNode parent;
/**
* constructor of GTNode
*/
public GTNode(Object obj){
super(obj);
parent=null;
}
/**
* return parent node.
*/
public GTNode parent(){
return parent;
}
/**
* set parent node.
*/
public void setParent(GTNode par){
parent=par;
}
/**********************fill your node for the following functions.********************/
/**
* test if this node is a leaf.
*/
public boolean isLeaf(){
//fill your code here.
}
/**
* return leftmost child node.
*/
public GTNode leftmostChild(){
//fill your code here.
}
/**
* return next sibling node.
*/
public GTNode rightSibling(){
//fill your code here.
}
/**
* insert a node as the leftmost child node of this node.
*/
public void insertFirst(GTNode n){
//fill your code here.
}
/**
* insert a node as the next sibling node of this node.
*/
public void insertNext(GTNode n){
//fill your code here.
}
/**
* remove the leftmost child of this node.
*/
public void removeFirst(){
//fill your code here.
}
/**
* remove the next sibling of this node.
*/
public void removeNext(){
//fill your code here.
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?