1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 23:22:28 +08:00

feat: add DeletetNode

This commit is contained in:
dudaodong
2022-03-01 11:04:38 +08:00
parent dd1cbf2ee3
commit bf7db0ded2
3 changed files with 64 additions and 1 deletions

View File

@@ -79,3 +79,29 @@ func TestBSTree_InOrderTraverse(t *testing.T) {
t.Log(acturl)
assert.Equal([]int{2, 4, 5, 6, 7}, acturl)
}
func TestBSTree_DeletetNode(t *testing.T) {
assert := internal.NewAssert(t, "TestBSTree_DeletetNode")
bstree := NewBSTree(6)
comparator := &intComparator{}
bstree.InsertNode(7, comparator)
bstree.InsertNode(5, comparator)
bstree.InsertNode(2, comparator)
bstree.InsertNode(4, comparator)
bstree.Print()
// bstree.DeletetNode(4, comparator)
// bstree.Print()
// acturl1 := bstree.InOrderTraverse()
// t.Log(acturl1)
// assert.Equal([]int{2, 5, 6, 7}, acturl1)
bstree.DeletetNode(6, comparator)
bstree.Print()
acturl2 := bstree.InOrderTraverse()
t.Log(acturl2)
assert.Equal([]int{2, 5, 7}, acturl2)
}