Java Reference
In-Depth Information
}
return minValue;
}
}
// max is written in the same fashion, but with 'max'
// in place of 'min' everywhere in the code.
13. public int countBranches() {
return countBranches(overallRoot);
}
private int countBranches(IntTreeNode root) {
if (root == null ||
(root.left == null && root.right == null)) {
return 0;
} else {
return 1 + countBranches(root.left) +
countBranches(root.right);
}
}
14. A binary search tree is one that is ordered such that smaller nodes appear to the left
and larger nodes appear to the right.
15. (b), if duplicates are allowed; (c); and (e)
16. An inorder traversal of a BST will examine the elements in their sorted order. For
example, inorder traversal of a BST of integers will visit the integers in increasing
numerical order.
17. Here is the resulting tree:
Leia
Boba
R2D2
Darth
Luke
Chewy
Han
Jabba
Search WWH ::




Custom Search