bst

package
Version: v0.0.0-...-09f00c6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT 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 {
	// 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

type Item

type Item interface{}

type TreeNode

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

Jump to

Keyboard shortcuts

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