public void display(Node1 n) { if (n == null) { return; } display(n.leftLeaf); Console.Write(" " + n.number); display(n.rightLeaf); }
public void insert(int d) { if (isEmpty()) { root = new Node1(d); } else { root.insertData(ref root, d); } count++; }
public void insertData(ref Node1 node, int data) { if (node == null) { node = new Node1(data); } else if (node.number < data) { insertData(ref node.rightLeaf, data); } else if (node.number > data) { insertData(ref node.leftLeaf, data); } }
public bool search(Node1 node, int s) { if (node == null) { return(false); } if (node.number == s) { return(true); } else if (node.number < s) { return(search(node.rightLeaf, s)); } else if (node.number > s) { return(search(node.leftLeaf, s)); } return(false); }
public bool isLeaf(ref Node1 node) { return(node.rightLeaf == null && node.leftLeaf == null); }
public Node1(int value) { number = value; rightLeaf = null; leftLeaf = null; }
public BinaryTree() { root = null; count = 0; }