tree
Interface CompleteBinaryTree

All Superinterfaces:
BinaryTree, Tree

public interface CompleteBinaryTree
extends BinaryTree


Method Summary
 container.Position add(java.lang.Object elem)
          Adds a new external Position to the "end" of the heap tree -- as a child of an existing position, or as the root if the heap tree is empty.
 java.lang.Object remove()
          Removes the "last" position in the heap tree.
 
Methods inherited from interface tree.BinaryTree
hasLeft, hasRight, left, right
 
Methods inherited from interface tree.Tree
children, elements, isEmpty, isExternal, isInternal, isRoot, parent, positions, replace, root, size
 

Method Detail

add

public container.Position add(java.lang.Object elem)
Adds a new external Position to the "end" of the heap tree -- as a child of an existing position, or as the root if the heap tree is empty. This extends the underlying binary tree by adding 1 new node, so it may result in an improper binary tree. (By contrast, HW5's createExternal() added two children to a node at the same time, so it never created an improper binary tree.)

Parameters:
elem - - an Object to be added
Returns:
the Position created when elem is added

remove

public java.lang.Object remove()
Removes the "last" position in the heap tree.

Returns:
the element stored at the removed Position.