Esempio n. 1
0
        public static void FCNS()   // First Child Next Sibling. Children weten niet wie hun parent is, siblings weten niet wie hun vorige sibling is
        {
            FCNSTree <char> tree = new FCNSTree <char>(null);

            FCNSNode <char> A = new FCNSNode <char>('A', null, null);
            FCNSNode <char> B = new FCNSNode <char>('B', null, null);
            FCNSNode <char> C = new FCNSNode <char>('C', null, null);
            FCNSNode <char> D = new FCNSNode <char>('D', null, null);
            FCNSNode <char> E = new FCNSNode <char>('E', null, null);
            FCNSNode <char> F = new FCNSNode <char>('F', null, null);
            FCNSNode <char> G = new FCNSNode <char>('G', null, null);
            FCNSNode <char> H = new FCNSNode <char>('H', null, null);
            FCNSNode <char> I = new FCNSNode <char>('I', null, null);
            FCNSNode <char> J = new FCNSNode <char>('J', null, null);
            FCNSNode <char> K = new FCNSNode <char>('K', null, null);

            tree.root = A;
            A.child   = B;
            B.child   = F;
            F.sibling = G;
            B.sibling = C;
            C.sibling = D;
            D.child   = H;
            D.sibling = E;
            E.child   = I;
            I.sibling = J;
            J.child   = K;

            Console.WriteLine(tree.Size());
            tree.PrintPreOrder();
        }
Esempio n. 2
0
        public string PrintString(FCNSNode <T> node)
        {
            string s = node.data.ToString();

            if (node.firstChild != null)
            {
                s += ",FC(" + PrintString(node.firstChild) + ")";
            }

            if (node.nextSibling != null)
            {
                s += ",NS(" + PrintString(node.nextSibling) + ")";
            }

            return(s);
        }
Esempio n. 3
0
        public string PrintNode(FCNSNode <T> node, string spacing)
        {
            string s = spacing + node.data.ToString() + "\n";

            if (node.firstChild != null)
            {
                s += PrintNode(node.firstChild, spacing + "      ") + "\n";
            }

            if (node.nextSibling != null)
            {
                s += PrintNode(node.nextSibling, spacing) + "\n";
            }

            return(s);
        }
Esempio n. 4
0
        public int CheckNodes(FCNSNode <T> node)
        {
            int size = 0;

            if (node.firstChild != null)
            {
                size += CheckNodes(node.firstChild);
            }

            if (node.nextSibling != null)
            {
                size += CheckNodes(node.nextSibling);
            }

            return(size + 1);
        }