Program 21.7 Tree Sort

Program 21.7 demonstrates the utility of a sorted binary tree by storing ten random numbers into a tree, and then printing them out.

public class treesort {

  public static void main (String[] args) {
  
    treenode root = new treenode(Math.random());

    for (int i = 1; i < 10; i++) {
      root.store(Math.random());
    }
  
    root.print();
  
  }

}

Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
This Chapter
Examples
Home