Beispiel #1
0
 public int solution(Tree tree)
 {
     return(Longest(tree, tree.x, 0));
 }
Beispiel #2
0
 public Tree(int val, Tree l, Tree r)
 {
     x      = val;
     this.l = l;
     this.r = r;
 }
Beispiel #3
0
        public void getDownAnalysis(Tree tree)
        {
            string article1 = "", article2 = "";
            string noun1 = "", noun2 = "";
            string verb = "";
            int    step = 0;

            bool flag = false;

            Console.WriteLine("Going-Down Analysis:");

            search(tree.sons[0], typeNode.article, ref article1, ref flag);
            flag = false;

            search(tree, typeNode.noun, ref noun1, ref flag);
            flag = false;

            search(tree, typeNode.verb, ref verb, ref flag);
            flag = false;

            search(tree.sons[1], typeNode.article, ref article2, ref flag);
            flag = false;

            search(tree.sons[1], typeNode.noun, ref noun2, ref flag);
            flag = false;

            step++;
            Console.WriteLine("{0}) sentence => {1} {2} {3} {4} {5}", step, article1, noun1, verb, article2, noun2);

            step++;
            Console.WriteLine("{0}) subject => {1} {2}", step, article1, noun1);

            search(tree.sons[0], typeNode.article, ref article1, ref flag);
            if (flag)
            {
                step++;
                Console.WriteLine("{0}) article => {1}", step, article1);
            }
            flag = false;

            step++;
            Console.WriteLine("{0}) noun => {1}", step, noun1);

            step++;
            Console.WriteLine("{0}) predicate => {1} {2} {3}", step, verb, article2, noun2);

            step++;
            Console.WriteLine("{0}) verb => {1}", step, verb);

            step++;
            Console.WriteLine("{0}) object => {1} {2}", step, article2, noun2);


            search(tree.sons[1], typeNode.article, ref article2, ref flag);
            if (flag)
            {
                step++;
                Console.WriteLine("{0}) article => {1}", step, article2);
            }

            step++;
            Console.WriteLine("{0}) noun => {1}", step, noun2);
        }