Example #1
0
 public override void Iterate(ProcessData <T> pd, TRAVERSALORDER to)
 {
     if (nRoot != null)
     {
         RecIterate(nRoot, pd, to);
     }
 }
Example #2
0
        private void RecIterate(Node <T> nCurrent, ProcessData <T> pd, TRAVERSALORDER to)
        {
            if (to == TRAVERSALORDER.PRE_ORDER)
            {
                // Process the data in the current node
                pd(nCurrent.Data);
            }

            // If current's left child exists, recurse left
            if (nCurrent.Left != null)
            {
                RecIterate(nCurrent.Left, pd, to);
            }

            if (to == TRAVERSALORDER.IN_ORDER)
            {
                // Process the data in the current node
                pd(nCurrent.Data);
            }

            // If current's right child exists, recurse right
            if (nCurrent.Right != null)
            {
                RecIterate(nCurrent.Right, pd, to);
            }

            if (to == TRAVERSALORDER.POST_ORDER)
            {
                // Process the data in the current node
                pd(nCurrent.Data);
            }
        }
Example #3
0
 public abstract void Iterate(ProcessData <T> pd, TRAVERSALORDER to);