Exemplo n.º 1
0
        public Node(double key, int level)
        {
            this.key = key;
            this.level = level;

            this.left = this.right = null;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 5
0
 public Node(int level)
 {
     this.key = double.PositiveInfinity;
     this.level = level;
     this.left = this.right = null;
 }
Exemplo n.º 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;
            }
        }