jGrasp Visualization

Nicholas Duchon: Jun 19, 2019

Key Concepts:


import java.util.Random;

public class MyNode {
   static Random rn = new Random ();
   MyNode left, right;
   int v;
   String s;
   MyNode (String ps, int pv) {
      s = ps;
      v = pv;
   } // end String, int constructor
   MyNode (String ps, int pv, int n) {
      this (ps, pv);
      addChildren (this, n);
   } // end String, int, int constructor
   void addChildren (MyNode m, int n) {
      if (n == 0) return;
      String sa = String.format ("%c", 'a' + rn.nextInt (26));
      String sb = String.format ("%c", 'a' + rn.nextInt (26));
      m.left  = new MyNode (sa, rn.nextInt (100), n-1);
      m.right = new MyNode (sb, rn.nextInt (100), n-1);
   } // end method addChildren
   public static void main (String [] args) {
      MyNode root = new MyNode ("root", 123, 3);
   } // end method main
} // end class MyNode


Set breakpoint:

Choose debug

When the breakpoint happens, click and drag the target root:

Then get something like this, perhaps after clicking a few display control buttons:

Adjust text in display by clicking the wrench icon and change some of these values:

Nicholas Duchon