public void Insert(int val)
        {
            if (val <= Key)
            {
                if (left == null)
                {
                    left = new RankNode(val);
                }
                else
                {
                    left.Insert(val);
                }

                //Increment the count after each insert
                LeftSize++;
            }
            else
            {
                if (right == null)
                {
                    right = new RankNode(val);
                }
                else
                {
                    right.Insert(val);
                }
            }
        }
 public RankNode(int d)
 {
     Key      = d;
     LeftSize = 0;
     left     = null;
     right    = null;
 }
Beispiel #3
0
 public void insert(int d)
 {
     if (d <= data)
     {
         if (left != null)
         {
             left.insert(d);
         }
         else
         {
             left = new RankNode(d);
         }
         left_size++;
     }
     else
     {
         if (right != null)
         {
             right.insert(d);
         }
         else
         {
             right = new RankNode(d);
         }
     }
 }
 private void Inorder(RankNode root)
 {
     if (root != null)
     {
         Inorder(root.left);
         Console.WriteLine(root.Key);
         Inorder(root.right);
     }
 }
 public void Track(int x)
 {
     if (Root == null)
     {
         Root = new RankNode(x);
     }
     else
     {
         Root.Insert(x);
     }
 }
Beispiel #6
0
 public static void track(int number)
 {
     if (root == null)
     {
         root = new RankNode(number);
     }
     else
     {
         root.insert(number);
     }
 }
 public OrderTracker()
 {
     Root = null;
 }