예제 #1
0
        public void PreoderTest()
        {
            var tree = new SplayTree <int>();

            int[] array    = { 10, 15, 20, 30, 40, 50, 25, 27, 14, 13, 35, 45 };
            int[] preorder = { 45, 35, 13, 10, 27, 14, 20, 15, 25, 30, 40, 50 };
            foreach (var item in array)
            {
                tree.Insert(item);
            }
            Assert.AreEqual(array.Length, tree.Count);
            int i = 0;

            foreach (var item in tree.GetPreorderTraversal())
            {
                Assert.AreEqual(preorder[i++], item);
            }
        }