📄 htbalnodeuos.java
字号:
/* HtBalNodeUos.java
* ---------------------------------------------
* Copyright (c) 2001 University of Saskatchewan
* All Rights Reserved
* --------------------------------------------- */
package dslib.dictionary.bintree;
import dslib.tree.*;
/** A binary node with a height instance variable and a method to set the
height. It contains an item and references to left and right subtrees.
The height value represents the height of the subtree with the current
node as the root. */
public class HtBalNodeUos extends BinaryNodeUos
{
/** Height of the subtree with this node as root. */
protected int height;
/** Create a node with value y and height 0. <br>
Analysis: Time = O(1)
@param y item to be placed in the node */
public HtBalNodeUos(Object y)
{
super(y);
setHeight(1);
}
/** Height of the subtree with this node as root. <br>
Analysis: Time = O(1) */
public int height()
{
return height;
}
/** Set the node height equal to newHeight. <br>
Analysis: Time = O(1)
@param newHeight value to be stored as the height of the node */
public void setHeight(int newHeight)
{
height = newHeight;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -