public Node(double key, int level) { this.key = key; this.level = level; this.left = this.right = null; }
public BinTree(string representation) { root = new Node(0); stack = new Stack<Node>(); //string improved = representation; string improved = spaces(representation); string[] structure = improved.Split(' '); max = max_length(structure); stack.Push(root); build(structure, 0); re_build(ref root); }
public ThreadedNode(Node node) { this.key = node.Key; this.level = node.Level; this.left = this.right = null; this.is_threaded_left = this.is_threaded_right = false; }
private void build(ref ThreadedNode th_node, Node node) { if (node != null) { th_node = new ThreadedNode(node); build(ref th_node.left, node.left); build(ref th_node.right, node.right); } else th_node = null; }
public Node(int level) { this.key = double.PositiveInfinity; this.level = level; this.left = this.right = null; }
private void re_build(ref Node node) { if (node != null) { if (node.left != null) re_build(ref node.left); else if (node.left == null && Double.IsInfinity(node.Key)) node = null; } if (node != null) { if (node.right != null) re_build(ref node.right); else if (node.right == null && Double.IsInfinity(node.Key)) node = null; } }