12.General Trees§
C1
C2
C3
V
P
R
S1
S2
Children of V
Subtree rooted at V
Siblings of V
Ancestors of V
Root
Parent of V
// 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
}
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.