public btNode() { left = null; info = 0; randomEvent = null; right = null; }
public btNode(btNode lt, int i, string r, btNode rt) { left = lt; info = i; randomEvent = r; right = rt; }
public void traverseBack() { if (predStack.Count != 0) { c = (btNode)predStack.Pop(); } }
public void traverseRight() { btNode p = c; if (p.right != null) { c = c.right; predStack.Push(p); } }
//TRAVERSAL METHODS public void traverseLeft() { btNode p = c; if (p.left != null) { c = c.left; predStack.Push(p); } }
public void printNode(btNode t) { if (t != null) { //printNode(t.left); print("How Many Nodes: " + howmany); //currentNodeText.text = "How Many Nodes: " + howmany +"\nCurrent Node: "+t.info; print("Current Node: " + t.info); //leftChildText.text = "Left Child: "+t.left.info; print("Left Child: " + t.left.info); //rightChildText.text = "Right Child: " + t.right.info; print("Right Child: " + t.right.info); //printNode(t.right); } }
public void insert(int i, string r) { btNode p = c; btNode pred = null; while ((p != null) && (p.info != i)) { pred = p; if (i < p.info) { p = p.left; } else { p = p.right; } } if (p == null) { howmany++; p = new btNode(null, i, r, null); if (pred != null) { if (i < pred.info) { pred.left = p; } else { pred.right = p; } } else { c = p; } } }