/** * To check if HT is empty or not. * * @return true, if both subtrees are null */ public boolean isEmpty() { return left == null && right == null; } /** * To check if HT is a leaf. * * @return true, if actual HT is non-empty, but both subtrees are */ public boolean isLeaf() { return !isEmpty() && left.isEmpty() && right.isEmpty(); } public BitString[] encode(BitString[] codeTable, BitString path) { if (isLeaf()) { codeTable[name] = path; return null; } right.encode(codeTable, path.append(true)); left.encode(codeTable, path.append(false)); return codeTable; }