English | 简体中文
a binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. here implements two types of tree: BST(Binary Search Tree) and AVLT(Adelson-Velsky and Landis Tree).
Using go get
command to get the latest version
go get github.com/SeananXu/go-binarytree
Import it with:
import "github.com/SeananXu/go-binarytree"
and use binarytree
as the package name inside the code.
// Binary Search Tree
t := binarytree.NewBSTree(binarytree.IntCompareFunc)
// Adelson-Velsky and Landis Tree
t := binarytree.NewAVLTree(binarytree.IntCompareFunc)
// adds value
t.Add(1)
// removes value
t.Remove(1)
// min value
min := t.Min()
// max value
max := t.Max()
// get string of tree
str := t.String()
...
more BST cases click here, AVLT cases click here
The MIT License (MIT) - see LICENSE for more details