package edu.princeton.cs.algs4.growingtree.demos; import edu.princeton.cs.algs4.growingtree.experiments.RotationHeightLogger; import edu.princeton.cs.algs4.growingtree.framework.NodeProperties; import edu.princeton.cs.algs4.growingtree.framework.TreeVisualization; /** * This is a demo to instantiate each of the trees implemented in this * package. * @author Josh Israel * */ public class GrowingTreeDemo { public static void main(String[] args) { // If running on Mac, use Mac-style menu bar if (System.getProperty("os.name").equals("Mac OS X")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); } TreeVisualization vis = new TreeVisualization(); vis.addTree("BST", new NodeProperties(), new BSTInsertion(), new BSTSearch(), new BSTDeletion(), true); vis.addTree("Red-Black", new RBNodeProperties(), new RedBlackInsertion(), new BSTSearch(), new RedBlackDeletion(), new RotationHeightLogger()); vis.addTree("LLRB", new RBNodeProperties(), new LLRBInsertion(), new BSTSearch(), new LLRBDeletion()); vis.addTree("Splay", new NodeProperties(), (new SplayOperators()).new SplayInsertion(), (new SplayOperators()).new SplaySearch(), (new SplayOperators()).new SplayDeletion()); vis.addTree("Randomized", new NodeProperties(), new RandomizedBSTInsertion(), new BSTSearch(), new RandomizedBSTDeletion()); vis.addTree("AVL-1", new AVLNodeProperties(), new AVLInsertion(1), new BSTSearch(), new AVLDeletion(1)); vis.addTree("AVL-2", new AVLNodeProperties(), new AVLInsertion(2), new BSTSearch(), new AVLDeletion(2)); vis.addTree("RAVL", new AVLNodeProperties(), new AVLInsertion(), new BSTSearch(), new BSTDeletion()); vis.addTree("Rank Balanced", new RankNodeProperties(), new RankInsertion(), new BSTSearch(), new RankDeletion()); vis.start(); } }