June 2017
Beginner
1296 pages
69h 23m
English
... which is inserted into the binary tree by calling method insertNode (line 17). The program then performs preorder, inorder and postorder traversals (these will be explained shortly) of tree (lines 21, 24 and 27, respectively).
Tree<E>Class Tree<E> (Fig. 21.15, lines 44–101) requires its type argument to implement interface Comparable, so that each value inserted in the tree can be compared with the existing values to find the insertion point. The class’s private root (line 45) instance variable is a TreeNode<E> reference to the tree’s root node. Tree<E>’s constructor (line 48) initializes root to null to indicate that the tree is empty. The class contains method insertNode (lines 51–58) to insert a new node in the tree and ...