Write a static method, copy, that, given a binary tree, returns a copy of the tree. Because not every object implements the copy method, you should not copy objects to which the tree refers. This is referred to as a shallow copy. 12.12 Design a nonrecursive implementation of a binary tree that maintains node data in a Vector, data. In this implementation, element 0 of data references the root (if it exists). Every non-null element i of data finds its left and right children at locations 2i + 1 and 2(i + 1), respectively. (The inverse of these index relations suggests the parent of a nonroot node at i is found at location b(i − 1)/2c.) Any element of data that is not used to represent a node should maintain a null reference
Write a static method, copy, that, given a binary tree, returns a copy of
the tree. Because not every object implements the copy method, you should not
copy objects to which the tree refers. This is referred to as a shallow copy.
12.12 Design a nonrecursive implementation of a binary tree that maintains
node data in a Vector, data. In this implementation, element 0 of data references the root (if it exists). Every non-null element i of data finds its left and
right children at locations 2i + 1 and 2(i + 1), respectively. (The inverse of these
index relations suggests the parent of a nonroot node at i is found at location
b(i − 1)/2c.) Any element of data that is not used to represent a node should
maintain a null reference
Step by step
Solved in 8 steps with 3 images