mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
style(go): fix go code style
Make the classes and methods in the package private, in case misuse
This commit is contained in:
@@ -11,31 +11,31 @@ 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)
|
||||
fmt.Println("\n初始化的二叉树为:")
|
||||
bst.Print()
|
||||
bst.print()
|
||||
|
||||
// 获取根结点
|
||||
node := bst.GetRoot()
|
||||
node := bst.getRoot()
|
||||
fmt.Println("\n二叉树的根结点为:", node.Val)
|
||||
|
||||
// 查找结点
|
||||
node = bst.Search(5)
|
||||
node = bst.search(5)
|
||||
fmt.Println("\n查找到的结点对象为", node, ",结点值 =", node.Val)
|
||||
|
||||
// 插入结点
|
||||
node = bst.Insert(16)
|
||||
node = bst.insert(16)
|
||||
fmt.Println("\n插入结点后 16 的二叉树为:")
|
||||
bst.Print()
|
||||
bst.print()
|
||||
|
||||
// 删除结点
|
||||
bst.Remove(1)
|
||||
bst.remove(1)
|
||||
fmt.Println("\n删除结点 1 后的二叉树为:")
|
||||
bst.Print()
|
||||
bst.Remove(2)
|
||||
bst.print()
|
||||
bst.remove(2)
|
||||
fmt.Println("\n删除结点 2 后的二叉树为:")
|
||||
bst.Print()
|
||||
bst.Remove(4)
|
||||
bst.print()
|
||||
bst.remove(4)
|
||||
fmt.Println("\n删除结点 4 后的二叉树为:")
|
||||
bst.Print()
|
||||
bst.print()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user