30.22. General Trees¶
30.22.1. General Trees¶
30.22.1.1. General Trees¶
30.22.1.2. General Tree ADT¶
// General tree node ADT interface GTNode { Object value(); boolean isLeaf(); GTNode parent(); GTNode leftmostChild(); GTNode rightSibling(); void setValue(Object value); void setParent(GTNode par); void insertFirst(GTNode n); void insertNext(GTNode n); void removeFirst(); void removeNext(); } // General tree ADT interface GenTree { void clear(); // Clear the tree GTNode root(); // Return the root // Make the tree have a new root, give first child and sib void newroot(Object value, GTNode first, GTNode sib); void newleftchild(E value); // Add left child }
30.22.1.4. Rep: Lists of Children¶
30.22.1.5. Rep: Dynamic Node (Array)¶
30.22.1.6. Rep: Dynamic Node (linked list)¶
30.22.1.7. Rep: Lift-Child/Right-Sibling¶
30.22.1.8. Serialization¶
Serialization is the process of storing an object as a series of bytes.
A sequential tree serialization typically stores the node values as they would be enumerated by a preorder traversal, along with sufficient information to describe the tree's shape.