tree

package
v0.0.0-...-fdcae39 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 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 BinarySearchTree

type BinarySearchTree struct {
	*BinaryTree
	CompareFunc func(v, nodeV interface{}) int
}

BinarySearchTree 二叉搜索树

func NewBinarySearchTree

func NewBinarySearchTree(rootV interface{}, compareFunc func(v, nodeV interface{}) int) *BinarySearchTree

NewBinarySearchTree 初始化二叉搜索树

func (*BinarySearchTree) Delete

func (bst *BinarySearchTree) Delete(v interface{}) bool

Delete 删除二叉搜索树中的某个值

func (*BinarySearchTree) Find

func (bst *BinarySearchTree) Find(v interface{}) bool

Find 查找二叉搜索树中的某个值

func (*BinarySearchTree) Insert

func (bst *BinarySearchTree) Insert(v interface{}) bool

Insert 插入一个值到二叉搜索树中

func (*BinarySearchTree) Max

func (bst *BinarySearchTree) Max() interface{}

Max 返回二叉搜索树中的最大值

func (*BinarySearchTree) Min

func (bst *BinarySearchTree) Min() interface{}

Min 返回二叉搜索树中的最小值

type BinaryTree

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

BinaryTree 二叉树的结构体

func NewBinaryTree

func NewBinaryTree(rootV interface{}) *BinaryTree

NewBinaryTree 初始化一个二叉树

func (*BinaryTree) InOrderTraverse

func (bt *BinaryTree) InOrderTraverse() (result []interface{})

InOrderTraverse 使用递归方法的中序遍历

func (*BinaryTree) InOrderTraverseByStack

func (bt *BinaryTree) InOrderTraverseByStack() (result []interface{})

InOrderTraverseByStack 使用stack的中序遍历

func (*BinaryTree) PostOrderTraverse

func (bt *BinaryTree) PostOrderTraverse() (result []interface{})

PostOrderTraverse 使用递归方法的后序遍历

func (*BinaryTree) PostOrderTraverseByStack

func (bt *BinaryTree) PostOrderTraverseByStack() (result []interface{})

PostOrderTraverseByStack 使用stack的后序遍历

func (*BinaryTree) PostOrderTraverseByTwoStack

func (bt *BinaryTree) PostOrderTraverseByTwoStack() (result []interface{})

PostOrderTraverseByTwoStack 使用两个stack的后序遍历

func (*BinaryTree) PreOrderTraverse

func (bt *BinaryTree) PreOrderTraverse() (result []interface{})

PreOrderTraverse 使用递归方法的前序遍历

func (*BinaryTree) PreOrderTraverseByStack

func (bt *BinaryTree) PreOrderTraverseByStack() (result []interface{})

PreOrderTraverseByStack 使用stack的前序遍历

type Node

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

Node 二叉树的节点

func NewNode

func NewNode(data interface{}) *Node

NewNode 初始化一个节点

func (*Node) String

func (n *Node) String() string

Jump to

Keyboard shortcuts

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