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(); }
public static int Size(FCNSNode <T> node) { if (node == null) { return(0); } return(1 + Size(node.FirstChild) + Size(node.NextSibling)); }
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); }
public int Size() { return(FCNSNode <T> .Size(root)); }
public void PrintPreOrder() { FCNSNode <T> .PrintPreOrder(root); }
public void addNode(FCNSNode <T> node) { root.FirstChild = node; }
public FCNSTree() { root = new FCNSNode <T>(default(T)); }