mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-14 20:50:58 +00:00
refactor: Replace 结点 with 节点 (#452)
* Replace 结点 with 节点 Update the footnotes in the figures * Update mindmap * Reduce the size of the mindmap.png
This commit is contained in:
@@ -14,8 +14,8 @@ import (
|
||||
func TestAVLTree(t *testing.T) {
|
||||
/* 初始化空 AVL 树 */
|
||||
tree := newAVLTree()
|
||||
/* 插入结点 */
|
||||
// 请关注插入结点后,AVL 树是如何保持平衡的
|
||||
/* 插入节点 */
|
||||
// 请关注插入节点后,AVL 树是如何保持平衡的
|
||||
testInsert(tree, 1)
|
||||
testInsert(tree, 2)
|
||||
testInsert(tree, 3)
|
||||
@@ -27,28 +27,28 @@ func TestAVLTree(t *testing.T) {
|
||||
testInsert(tree, 10)
|
||||
testInsert(tree, 6)
|
||||
|
||||
/* 插入重复结点 */
|
||||
/* 插入重复节点 */
|
||||
testInsert(tree, 7)
|
||||
|
||||
/* 删除结点 */
|
||||
// 请关注删除结点后,AVL 树是如何保持平衡的
|
||||
testRemove(tree, 8) // 删除度为 0 的结点
|
||||
testRemove(tree, 5) // 删除度为 1 的结点
|
||||
testRemove(tree, 4) // 删除度为 2 的结点
|
||||
/* 删除节点 */
|
||||
// 请关注删除节点后,AVL 树是如何保持平衡的
|
||||
testRemove(tree, 8) // 删除度为 0 的节点
|
||||
testRemove(tree, 5) // 删除度为 1 的节点
|
||||
testRemove(tree, 4) // 删除度为 2 的节点
|
||||
|
||||
/* 查询结点 */
|
||||
/* 查询节点 */
|
||||
node := tree.search(7)
|
||||
fmt.Printf("\n查找到的结点对象为 %#v ,结点值 = %d \n", node, node.Val)
|
||||
fmt.Printf("\n查找到的节点对象为 %#v ,节点值 = %d \n", node, node.Val)
|
||||
}
|
||||
|
||||
func testInsert(tree *aVLTree, val int) {
|
||||
tree.insert(val)
|
||||
fmt.Printf("\n插入结点 %d 后,AVL 树为 \n", val)
|
||||
fmt.Printf("\n插入节点 %d 后,AVL 树为 \n", val)
|
||||
PrintTree(tree.root)
|
||||
}
|
||||
|
||||
func testRemove(tree *aVLTree, val int) {
|
||||
tree.remove(val)
|
||||
fmt.Printf("\n删除结点 %d 后,AVL 树为 \n", val)
|
||||
fmt.Printf("\n删除节点 %d 后,AVL 树为 \n", val)
|
||||
PrintTree(tree.root)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user