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); } } } }
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); } } } }
Node <T> FindMinor(MultiPathNode <T> actualNode) { Node <T> head = actualNode.GetHead(); if (head.LeftChild != null) { return(FindMinor(head.LeftChild)); } else { return(head); } }
public MultiPathTree(int dgree) { if (dgree < 2) { Root = new MultiPathNode <T>(2); degree = 2; } else { Root = new MultiPathNode <T>(dgree); degree = dgree; } }
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; } }
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); } } }