searchtree

package
v0.0.0-...-4c03c20 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 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 BinarySearchTree

type BinarySearchTree struct {
	Root *Node
	// contains filtered or unexported fields
}

func (*BinarySearchTree) Get

func (bst *BinarySearchTree) Get(key string) Item

Search returns the item if it exists, else returns an empty string

func (*BinarySearchTree) InOrderTraverse

func (bst *BinarySearchTree) InOrderTraverse(f func(Item))

func (*BinarySearchTree) Insert

func (bst *BinarySearchTree) Insert(key string, value Item)

func (*BinarySearchTree) Max

func (bst *BinarySearchTree) Max() *Item

Max returns the Item with max Value stored in the tree

func (*BinarySearchTree) Min

func (bst *BinarySearchTree) Min() *Item

Min returns the Item with min Value stored in the tree

func (*BinarySearchTree) PostOrderTraverse

func (bst *BinarySearchTree) PostOrderTraverse(f func(Item))

PostOrderTraverse visits all nodes with post-order traversing

func (*BinarySearchTree) PreOrderTraverse

func (bst *BinarySearchTree) PreOrderTraverse(f func(Item))

PreOrderTraverse visits all nodes with pre-order traversing

func (*BinarySearchTree) Remove

func (bst *BinarySearchTree) Remove(key string)

Remove removes the Item with key `key` from the tree

func (*BinarySearchTree) Search

func (bst *BinarySearchTree) Search(key string) bool

Search returns true if the Item t exists in the tree

func (*BinarySearchTree) String

func (bst *BinarySearchTree) String() string

type Item

type Item string

type Node

type Node struct {
	Key   string
	Value Item
	Left  *Node
	Right *Node
}

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