public PopulateFCNSTree()
        {
            FCNSTree <string> tree  = new FCNSTree <string>();
            FCNSNode <string> nodeB = new FCNSNode <string>("B");
            FCNSNode <string> nodeC = new FCNSNode <string>("C");
            FCNSNode <string> nodeD = new FCNSNode <string>("D");
            FCNSNode <string> nodeE = new FCNSNode <string>("E");
            FCNSNode <string> nodeF = new FCNSNode <string>("F");
            FCNSNode <string> nodeG = new FCNSNode <string>("G");
            FCNSNode <string> nodeH = new FCNSNode <string>("H");
            FCNSNode <string> nodeI = new FCNSNode <string>("I");
            FCNSNode <string> nodeJ = new FCNSNode <string>("J");
            FCNSNode <string> nodeK = new FCNSNode <string>("K");

            nodeJ.FirstChild  = nodeK;
            nodeI.NextSibling = nodeJ;
            nodeE.FirstChild  = nodeI;
            nodeD.FirstChild  = nodeH;
            nodeD.NextSibling = nodeE;
            nodeC.NextSibling = nodeD;
            nodeB.NextSibling = nodeC;
            nodeB.FirstChild  = nodeF;
            nodeF.NextSibling = nodeG;

            tree.addNode(nodeB);
            Console.WriteLine($"De grootte van de tree is {tree.Size()}");

            tree.PrintPreOrder();
        }
Beispiel #2
0
 public static int Size(FCNSNode <T> node)
 {
     if (node == null)
     {
         return(0);
     }
     return(1 + Size(node.FirstChild) + Size(node.NextSibling));
 }
Beispiel #3
0
 public static void PrintPreOrder(FCNSNode <T> node, int level = 0)
 {
     if (node == null)
     {
         return;
     }
     if (level == 0)
     {
         Console.WriteLine("ROOT A");
     }
     else
     {
         for (int teller = 0; teller < level; teller++)
         {
             Console.Write("-->\t");
         }
         Console.WriteLine(node.get());
     }
     PrintPreOrder(node.FirstChild, level + 1);
     PrintPreOrder(node.NextSibling, level);
 }
Beispiel #4
0
 public int Size()
 {
     return(FCNSNode <T> .Size(root));
 }
Beispiel #5
0
 public void PrintPreOrder()
 {
     FCNSNode <T> .PrintPreOrder(root);
 }
Beispiel #6
0
 public void addNode(FCNSNode <T> node)
 {
     root.FirstChild = node;
 }
Beispiel #7
0
 public FCNSTree()
 {
     root = new FCNSNode <T>(default(T));
 }