Documentation
¶
Index ¶
- type BinarySearchTree
- func (bst *BinarySearchTree) InOrderTraverse(fn func(Item))
- func (bst *BinarySearchTree) Insert(key int, value Item)
- func (bst *BinarySearchTree) Max() *Item
- func (bst *BinarySearchTree) Min() *Item
- func (bst *BinarySearchTree) PostOrderTraverse(fn func(Item))
- func (bst *BinarySearchTree) PreOrderTraverse(fn func(Item))
- func (bst *BinarySearchTree) Remove(key int)
- func (bst *BinarySearchTree) Search(key int) bool
- type Item
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinarySearchTree ¶
type BinarySearchTree struct {
// contains filtered or unexported fields
}
func (*BinarySearchTree) InOrderTraverse ¶
func (bst *BinarySearchTree) InOrderTraverse(fn func(Item))
InOrderTraverse visits all the nodes in order
func (*BinarySearchTree) Insert ¶
func (bst *BinarySearchTree) Insert(key int, value Item)
Insert inserts the element with the given key and value in the BST
func (*BinarySearchTree) Max ¶
func (bst *BinarySearchTree) Max() *Item
Max returns the item with the maximum value stored in the tree
func (*BinarySearchTree) Min ¶
func (bst *BinarySearchTree) Min() *Item
Min returns the item with the minimum value stored in the tree
func (*BinarySearchTree) PostOrderTraverse ¶
func (bst *BinarySearchTree) PostOrderTraverse(fn func(Item))
PostOrderTraverse traverses all the nodes in a post order method (left -> right -> current node)
func (*BinarySearchTree) PreOrderTraverse ¶
func (bst *BinarySearchTree) PreOrderTraverse(fn func(Item))
PreOrderTraverse visits all the tree nodes with preorder traversing
func (*BinarySearchTree) Remove ¶
func (bst *BinarySearchTree) Remove(key int)
Remove removes the item with the passed in key from the tree
func (*BinarySearchTree) Search ¶
func (bst *BinarySearchTree) Search(key int) bool
Search returns true if the Item exists in the tree
Click to show internal directories.
Click to hide internal directories.