public static int Size(FCNSNode n) { if (n == null) { return(0); } else { return(1 + Size(n.FirstChild) + Size(n.NextSibling)); } }
public static IFirstChildNextSibling <string> CreateFirstChildNextSibling_Small() { FirstChildNextSibling <string> tree = new FirstChildNextSibling <string> (); FCNSNode <string> d = new FCNSNode <string> ("d"); FCNSNode <string> c = new FCNSNode <string> ("c"); FCNSNode <string> b = new FCNSNode <string> ("b", d, c); FCNSNode <string> a = new FCNSNode <string> ("a", b, null); tree.root = a; return(tree); }
public int Size(FCNSNode <T> node) { int size = 1; if (node.FirstChild != null) { size += Size(node.FirstChild); } if (node.NextSibling != null) { size += Size(node.NextSibling); } return(size); }
public static IFirstChildNextSibling <string> CreateFirstChildNextSibling_18_3() { FirstChildNextSibling <string> tree = new FirstChildNextSibling <string>(); FCNSNode <string> k = new FCNSNode <string>("k"); FCNSNode <string> j = new FCNSNode <string>("j", k, null); FCNSNode <string> i = new FCNSNode <string>("i", null, j); FCNSNode <string> e = new FCNSNode <string>("e", i, null); FCNSNode <string> h = new FCNSNode <string>("h"); FCNSNode <string> d = new FCNSNode <string>("d", h, e); FCNSNode <string> c = new FCNSNode <string>("c", null, d); FCNSNode <string> g = new FCNSNode <string>("g"); FCNSNode <string> f = new FCNSNode <string>("f", null, g); FCNSNode <string> b = new FCNSNode <string>("b", f, c); FCNSNode <string> a = new FCNSNode <string>("a", b, null); tree.root = a; return(tree); }
private void PrintPreOrder(FCNSNode <T> node, int indent) { for (int i = 0; i < indent; i++) { Console.Write("\t"); } if (node.Data != null) { Console.Write(node.Data); } else { Console.Write("(...)"); } if (node.FirstChild != null) { PrintPreOrder(node.FirstChild, indent + 1); } if (node.NextSibling != null) { Console.WriteLine("\n"); PrintPreOrder(node.NextSibling, indent); } }
public FCNSNode(T data, FCNSNode <T> firstChild, FCNSNode <T> nextSibling) { this.data = data; this.firstChild = firstChild; this.nextSibling = nextSibling; }
public FCNSTree(FCNSNode rootNode) { Root = rootNode; }
public FCNSTree(T rootElement) { Root = new FCNSNode(rootElement); }
public FCNSTree() { Root = null; }
public FCNSTree(FCNSNode <T> r) { Root = r; }
public FCNSNode(T data) { this.data = data; nextSibling = firstChild = null; }