mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-11 06:56:06 +00:00
fix binary_search_tree code
This commit is contained in:
@@ -10,8 +10,12 @@ import (
|
||||
)
|
||||
|
||||
func TestBinarySearchTree(t *testing.T) {
|
||||
nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
|
||||
bst := newBinarySearchTree(nums)
|
||||
bst := newBinarySearchTree()
|
||||
nums := []int{8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15}
|
||||
// 请注意,不同的插入顺序会生成不同的二叉树,该序列可以生成一个完美二叉树
|
||||
for _, num := range nums {
|
||||
bst.insert(num)
|
||||
}
|
||||
fmt.Println("\n初始化的二叉树为:")
|
||||
bst.print()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user