CS3114/5040 S26 Coursenotes

Chapter 10 Week 11

| About   «  10.3. Project 4   ::   Contents   ::   11.1. Indexing  »

10.4. General Trees

10.4.1. General Trees

10.4.2. General Tree ADT

// General tree node ADT
public interface GTNode {
  public Object value();
  public boolean isLeaf();
  public GTNode parent();
  public GTNode leftmostChild();
  public GTNode rightSibling();
  public void setValue(Object value);
  public void setParent(GTNode par);
  public void insertFirst(GTNode n);
  public void insertNext(GTNode n);
  public void removeFirst();
  public void removeNext();
}

// General tree ADT
public interface GenTree {
  public void clear();      // Clear the tree
  public GTNode root();     // Return the root
  // Make the tree have a new root, give first child and sib
  public void newroot(Object value, GTNode first, GTNode sib);
  public void newleftchild(E value); // Add left child
}

10.4.3. General Tree Traversal

10.4.4. Representation: Lists of Children

The "list of children" implementation for general trees.

10.4.5. Representation: Dynamic Node (Array)

A dynamic general tree with fixed-size arrays

10.4.6. Representation: Dynamic Node (linked list)

A dynamic general tree with linked lists of child pointers

10.4.7. Representation: Left-Child/Right-Sibling

Converting from a forest of general trees to a binary tree

10.4.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.

10.4.9. Binary tree serialization

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

10.4.10. Alternate serialization

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

10.4.11. Bit Vector Serialization

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

10.4.12. General Tree Serialization

Settings

Proficient Saving... Error Saving
Server Error
Resubmit

   «  10.3. Project 4   ::   Contents   ::   11.1. Indexing  »

Close Window