Example #1
0
        public void Remove_leafs()
        {
            var bst = new ArrayBst <int>(int.MinValue, 16);

            bst.Add(5);
            bst.Add(3);
            bst.Add(8);
            bst.Add(1);
            bst.Add(4);
            bst.Add(6);
            bst.Add(9);
            bst.Add(7);

            bst.Remove(1);
            Assert.False(bst.Find(1));

            bst.Remove(9);
            Assert.False(bst.Find(9));
        }
Example #2
0
        public void Remove_internal_node()
        {
            var bst = new ArrayBst <int>(int.MinValue, 16);

            bst.Add(5);
            bst.Add(3);
            bst.Add(8);
            bst.Add(1);
            bst.Add(4);
            bst.Add(6);
            bst.Add(9);
            bst.Add(7);

            bst.Remove(8);
            Assert.False(bst.Find(8));
            Assert.True(bst.Find(6));

            bst.Remove(3);
            Assert.False(bst.Find(3));
            Assert.True(bst.Find(1));
        }