AVL

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvlTree

type AvlTree struct {
	Root *AvlTreeNode // 树根节点
}

AvlTree AVL树

func NewAVLTree

func NewAVLTree() *AvlTree

NewAVLTree 初始化一个AVL树

func (*AvlTree) Add

func (tree *AvlTree) Add(value int)

func (*AvlTree) Find

func (tree *AvlTree) Find(value int) *AvlTreeNode

Find 查找指定节点

func (*AvlTree) FindMaxValue

func (tree *AvlTree) FindMaxValue() *AvlTreeNode

FindMaxValue 找出最大值的节点

func (*AvlTree) FindMinValue

func (tree *AvlTree) FindMinValue() *AvlTreeNode

FindMinValue 找出最小值的节点

func (*AvlTree) MidOrder

func (tree *AvlTree) MidOrder()

MidOrder 中序遍历

type AvlTreeNode

type AvlTreeNode struct {
	Value  int          // 值
	Times  int          // 值出现的次数
	Height int          // 该节点作为树根节点,树的高度,方便计算平衡因子
	Left   *AvlTreeNode // 左子树
	Right  *AvlTreeNode // 右字树
	// contains filtered or unexported fields
}

AvlTreeNode AVL节点

func LeftRightRotation

func LeftRightRotation(node *AvlTreeNode) *AvlTreeNode

LeftRightRotation 先左后右旋操作

func LeftRotation

func LeftRotation(Root *AvlTreeNode) *AvlTreeNode

LeftRotation 单左旋操作

func RightLeftRotation

func RightLeftRotation(node *AvlTreeNode) *AvlTreeNode

RightLeftRotation 先右后左旋操作

func RightRotation

func RightRotation(Root *AvlTreeNode) *AvlTreeNode

RightRotation 单右旋操作

func (*AvlTreeNode) BalanceFactor

func (node *AvlTreeNode) BalanceFactor() int

BalanceFactor 计算平衡因子

func (*AvlTreeNode) UpdateHeight

func (node *AvlTreeNode) UpdateHeight()

UpdateHeight 更新节点的树高度

type KV

type KV struct {
	// contains filtered or unexported fields
}

KV 节点

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL