February 2014
Beginner
1248 pages
62h 25m
English
Class Tree’s method insertNode (lines 56–62) first determines whether the tree is empty. If so, line 59 allocates a new TreeNode, initializes the node with the value being inserted in the tree and assigns the new node to reference root. If the tree is not empty, line 61 calls TreeNode method insert (lines 21–41). This method uses recursion to determine the location for the new node in the tree and inserts the node at that location. A node can be inserted only as a leaf node in a binary search tree.
Read now
Unlock full access