_4_tree

package
v0.0.0-...-b03bf0d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BST

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

func (*BST) InOrderTraverse

func (bst *BST) InOrderTraverse(f func(int))

InOrderTraverse 中序遍历

func (*BST) Insert

func (bst *BST) Insert(val int) *BST

Insert 插入一个元素

func (*BST) Max

func (bst *BST) Max() (int, bool)

Max 二叉搜索树的最大值

func (*BST) Min

func (bst *BST) Min() (int, bool)

Min 二叉搜索树的最小值

func (*BST) PostOrderTraverse

func (bst *BST) PostOrderTraverse(f func(int))

PostOrderTraverse 后序遍历

func (*BST) PreOrderTraverse

func (bst *BST) PreOrderTraverse(f func(int))

PreOrderTraverse 前序遍历

func (*BST) Remove

func (bst *BST) Remove(val int) bool

Remove 删除一个元素

func (*BST) Search

func (bst *BST) Search(val int) bool

Search 搜索元素(检查元素是否存在)

type Node

type Node struct {
	Value    int
	Children []*Node
}

func (*Node) BreadthFirstSearch

func (n *Node) BreadthFirstSearch() (bfs []int)

func (*Node) DepthFirstSearch

func (n *Node) DepthFirstSearch(array []int) []int

type TreeNode

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

https://colobu.com/2020/07/15/implement-bst-in-Go/ 二叉搜索树(binary search tree,BST)也叫排序的二叉树,根节点比左边子树的所有节点都大,比右边子树上的所有节点都小

func NewTreeNode

func NewTreeNode(val int) *TreeNode

func (*TreeNode) String

func (n *TreeNode) String()

String prints a visual representation of the tree

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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