Skip to content

Latest commit

 

History

History
executable file
·
11 lines (8 loc) · 611 Bytes

7041.md

File metadata and controls

executable file
·
11 lines (8 loc) · 611 Bytes

Back to questions

7041: Cloning tree nodes

Consider again the TreeNode class of question 96df---the original class, not your set of improved classes.

Extend TreeNode with a clone() method that, when invoked on a TreeNode instance, creates and returns a copy of the subtree rooted at the given node. All aspects of a node should be cloned, apart from the key, which should not be cloned. (Because of this, the result will not be a true "deep copy": the copy and the original will share the same key object. Hence, this copy might actually be called "semi-deep".)