mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
feat(tree/avl_tree): add go code
This commit is contained in:
@@ -9,16 +9,18 @@ import (
|
||||
)
|
||||
|
||||
type TreeNode struct {
|
||||
Val int
|
||||
Left *TreeNode
|
||||
Right *TreeNode
|
||||
Val int // 结点值
|
||||
Height int // 结点高度
|
||||
Left *TreeNode // 左子结点引用
|
||||
Right *TreeNode // 右子结点引用
|
||||
}
|
||||
|
||||
func NewTreeNode(v int) *TreeNode {
|
||||
return &TreeNode{
|
||||
Left: nil,
|
||||
Right: nil,
|
||||
Val: v,
|
||||
Val: v,
|
||||
Height: 0,
|
||||
Left: nil,
|
||||
Right: nil,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user