Ejemplo n.º 1
0
        private void RecursivePreOrder(List <T> _list, MultiPathNode <T> actualNode)
        {
            if (actualNode != null)
            {
                Node <T> head = actualNode.GetHead();

                if (head != null)
                {
                    _list.Add(head.t_object);
                    Node <T> aux = head;
                    while (aux.next != null)
                    {
                        aux = aux.next;

                        _list.Add(aux.t_object);
                    }
                    aux = head;
                    RecursivePreOrder(_list, head.LeftChild);
                    RecursivePreOrder(_list, head.RightChild);
                    while (aux.next != null)
                    {
                        aux = aux.next;
                        RecursivePreOrder(_list, aux.RightChild);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void OriginalRecursivePostOrder(List <T> _list, MultiPathNode <T> actualNode) //Explicado en clase
        {
            if (actualNode != null)
            {
                Node <T> head = actualNode.GetHead();
                if (head != null)
                {
                    OriginalRecursivePostOrder(_list, head.LeftChild);
                    OriginalRecursivePostOrder(_list, head.RightChild);
                    Node <T> aux = head;
                    while (aux.next != null)
                    {
                        aux = aux.next;
                        OriginalRecursivePostOrder(_list, aux.RightChild);
                    }
                    _list.Add(head.t_object);
                    aux = head;
                    while (aux.next != null)
                    {
                        aux = aux.next;

                        _list.Add(aux.t_object);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        Node <T> FindMinor(MultiPathNode <T> actualNode)
        {
            Node <T> head = actualNode.GetHead();

            if (head.LeftChild != null)
            {
                return(FindMinor(head.LeftChild));
            }
            else
            {
                return(head);
            }
        }
Ejemplo n.º 4
0
 public MultiPathTree(int dgree)
 {
     if (dgree < 2)
     {
         Root   = new MultiPathNode <T>(2);
         degree = 2;
     }
     else
     {
         Root   = new MultiPathNode <T>(dgree);
         degree = dgree;
     }
 }
Ejemplo n.º 5
0
        void CreateNode(Node <T> dad, T newValue, bool headLeft)
        {
            MultiPathNode <T> newNode = new MultiPathNode <T>(degree);

            newNode.Enlist(newValue);
            if (headLeft)
            {
                dad.LeftChild = newNode;
            }
            else
            {
                dad.RightChild = newNode;
            }
        }
Ejemplo n.º 6
0
 bool RecursiveInsert(T value, MultiPathNode <T> SubTree)
 {
     if (!SubTree.IsFull())
     {
         SubTree.Enlist(value);
         return(true);
     }
     else
     {
         Node <T> aux = new Node <T>();
         aux = SubTree.PeekNode(value);
         if (aux != null)
         {
             if (aux.prev == null && value.CompareTo(aux.t_object) < 0)
             {
                 if (aux.LeftChild != null)
                 {
                     return(RecursiveInsert(value, aux.LeftChild));
                 }
                 else
                 {
                     CreateNode(aux, value, true);
                     return(true);
                 }
             }
             else
             {
                 if (aux.RightChild != null)
                 {
                     return(RecursiveInsert(value, aux.RightChild));
                 }
                 else
                 {
                     CreateNode(aux, value, false);
                     return(true);
                 }
             }
         }
         else
         {
             return(false);
         }
     }
 }