Exemplo n.º 1
0
        public TreeQueue <T> Breadth()
        {
            TreeQueue <T> q = new TreeQueue <T>();

            q.Front = Root;
            return(BreadthList(q));
        }
Exemplo n.º 2
0
        private TreeQueue <T> BreadthList(TreeQueue <T> q)
        {
            TreeQueue <T> list = new TreeQueue <T>();

            while (q.Front != null)
            {
                if (q.Front.Left != null)
                {
                    q.EnQueueNode(q.Front.Left);
                }

                if (q.Front.Right != null)
                {
                    q.EnQueueNode(q.Front.Right);
                }
                list.EnQueue(q.DeQueue());
            }
            return(list);
        }
Exemplo n.º 3
0
        public BinaryTree <T> TreeBuilder(TreeQueue <T> q)
        {
            Root    = q.Front;
            Current = Root;
            var current = Current;

            current = current.Next;
            while (true)
            {
                Current.Left = current;
                current      = current.Next;
                if (current == null)
                {
                    return(this);
                }
                Current.Right = current;
                current       = current.Next;
                if (current == null)
                {
                    return(this);
                }
                Current = Current.Next;
            }
        }