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

feat: update deleteTreeNode func

This commit is contained in:
dudaodong
2022-03-01 11:13:44 +08:00
parent bf7db0ded2
commit aa28479d11
3 changed files with 44 additions and 10 deletions

View File

@@ -93,15 +93,32 @@ func TestBSTree_DeletetNode(t *testing.T) {
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.DeletetNode(4, comparator)
bstree.Print()
acturl2 := bstree.InOrderTraverse()
t.Log(acturl2)
assert.Equal([]int{2, 5, 7}, acturl2)
acturl1 := bstree.InOrderTraverse()
t.Log(acturl1)
assert.Equal([]int{2, 5, 6, 7}, acturl1)
//todo
// bstree.DeletetNode(6, comparator)
// bstree.Print()
// acturl2 := bstree.InOrderTraverse()
// t.Log(acturl2)
// assert.Equal([]int{2, 5, 7}, acturl2)
}
func TestBSTree_Depth(t *testing.T) {
assert := internal.NewAssert(t, "TestBSTree_Depth")
bstree := NewBSTree(6)
comparator := &intComparator{}
bstree.InsertNode(7, comparator)
bstree.InsertNode(5, comparator)
bstree.InsertNode(2, comparator)
bstree.InsertNode(4, comparator)
bstree.Print()
assert.Equal(bstree.Depth(), 4)
}