PPT Slide
public TreeNode getNodeRecursively
(int index, TreeNode currentNode)
throws MissingNodeException {
if (currentNode == null) {
throw new MissingNodeException
(“Exception: No node with ” + index + “ found”);
else if (currentNode.getNumber() == index) {
else if (currentNode.getNumber() > index) {
return getNodeRecursively (index, currentNode.getLeftChild());
return getNodeRecursively (index, currentNode.getRightChild());
When to Use Exceptions: Contract Violated