Exemplo n.º 1
0
        public int[] InoredBypassMethod_CreateTreeAndGetItInoredBypass(int[] array)
        {
            Tree.BinaryTree <int> binaryTree = new Tree.BinaryTree <int>();
            foreach (var element in array)
            {
                binaryTree.Add(element);
            }

            int[] result = new int[array.Length];
            int   i      = 0;

            foreach (var value in binaryTree.InorderBypass())
            {
                result[i++] = value;
            }

            return(result);
        }
Exemplo n.º 2
0
        public void InoredBypassMethod_CreateTreeWithStringAndGetItInoredBypass()
        {
            string[] elements       = new string[] { "fffff", "kkkkkkkkk", "aaaa", "c" };
            string[] expectedResult = new string[] { "c", "aaaa", "fffff", "kkkkkkkkk" };

            Tree.BinaryTree <string> binaryTree = new Tree.BinaryTree <string>((left, right) => left.Length.CompareTo(right.Length));
            foreach (var element in elements)
            {
                binaryTree.Add(element);
            }

            string[] result = new string[elements.Length];
            int      i      = 0;

            foreach (var value in binaryTree.InorderBypass())
            {
                result[i++] = value;
            }

            Assert.AreEqual(expectedResult, result);
        }