Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxCombine ¶
func MinCombine ¶
Types ¶
type AVLTree ¶
type AVLTree struct { Root *AVLNode // contains filtered or unexported fields }
AVLTree represents an AVL tree
func (*AVLTree) InOrderTraversal ¶
InOrderTraversal performs inorder traversal of the tree
type BTree ¶
type BTree struct {
// contains filtered or unexported fields
}
BTree represents a B-tree
func (*BTree) GetInOrder ¶
GetInOrder returns all keys in the B-tree in sorted order
type BTreeNode ¶
type BTreeNode struct {
// contains filtered or unexported fields
}
BTreeNode represents a node in B-tree
type IBinaryTree ¶
type IBinaryTree interface { Insert(data int) Search(data int) Exists(data int) bool Delete(data int) Max() int Min() int Print(pType string) List(pType string) []int }
func BinaryTree ¶
func BinaryTree(data int) IBinaryTree
type RedBlackTree ¶
type RedBlackTree struct { Root *RBNode NIL *RBNode // Sentinel node // contains filtered or unexported fields }
RedBlackTree represents a Red-Black tree
func NewRedBlackTree ¶
func NewRedBlackTree() *RedBlackTree
NewRedBlackTree creates a new Red-Black tree
func (*RedBlackTree) InOrderTraversal ¶
func (t *RedBlackTree) InOrderTraversal(result *[]int)
InOrderTraversal performs an inorder traversal of the tree
func (*RedBlackTree) Insert ¶
func (t *RedBlackTree) Insert(key int)
Insert adds a new key to the tree
func (*RedBlackTree) Search ¶
func (t *RedBlackTree) Search(key int) bool
Search looks for a key in the tree
type SegmentTree ¶
type SegmentTree struct {
// contains filtered or unexported fields
}
SegmentTree represents a segment tree data structure
func NewSegmentTree ¶
func NewSegmentTree(arr []int, combine func(int, int) int) *SegmentTree
NewSegmentTree creates a new segment tree from an array
func (*SegmentTree) GetArray ¶
func (st *SegmentTree) GetArray() []int
GetArray returns the current array
func (*SegmentTree) Query ¶
func (st *SegmentTree) Query(left int, right int) int
Query returns the result of the combine function over the range [left, right]
func (*SegmentTree) Update ¶
func (st *SegmentTree) Update(i int, val int)
Update updates the value at index i to val
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie represents a Trie (prefix tree)
func (*Trie) GetAllWords ¶
GetAllWords returns all words stored in the trie
func (*Trie) GetWordsWithPrefix ¶
GetWordsWithPrefix returns all words that start with the given prefix
func (*Trie) StartsWith ¶
StartsWith returns true if there is any word in the trie that starts with the given prefix