示例#1
0
        public Node(double key, int level)
        {
            this.key = key;
            this.level = level;

            this.left = this.right = null;
        }
示例#2
0
        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);
        }
示例#3
0
 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;
 }
示例#4
0
 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;
 }
示例#5
0
 public Node(int level)
 {
     this.key = double.PositiveInfinity;
     this.level = level;
     this.left = this.right = null;
 }
示例#6
0
        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;
            }
        }