Exemple #1
0
        static void Main(string[] args)
        {
            Bst bst = new Bst();

            bst.Insert(4);
            bst.Insert(5);
            bst.Insert(6);
            bst.Insert(5);
            bst.DeleteItem(5);

            Bst bst1 = new Bst();

            bst1.Insert(6);
            bst1.Insert(5);
            bst1.Insert(3);

            Console.Write($"{bst.SameData(bst1)}\n");

            bst.PrintDescending();
            Console.Write(bst.Sum());

            Tutor t = new Tutor();

            Console.WriteLine(t.Task1Rec(3));

            Console.WriteLine(t.Prod(6, -5));


            LinkedList list = new LinkedList();

            list.AddItem(3);
            list.AddItem(5);
            list.AddItem(-3);
            list.AddItem(1);
            list.AddItem(0);
            list.AddItem(4);
            list.AddItem(2);
            Console.WriteLine(list.Sum());
            list.Print();
            list.PrindRev();
        }
Exemple #2
0
        public bool SameData(Bst bst)
        {
            List <int> list1 = new List <int>();
            List <int> list2 = new List <int>();

            ToListRec(list1, _root);
            ToListRec(list2, bst._root);

            if (list1.Count != list2.Count)
            {
                return(false);
            }

            foreach (int i in list1)
            {
                if (!list2.Contains(i))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
 public bool IsEquals(Bst tree)
 {
     IsEqualsRec(this._root, tree._root, out bool res);
     return(res);
 }