1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 06:32:28 +08:00

feat: add BSTree which is binary search tree

This commit is contained in:
dudaodong
2022-02-21 16:48:27 +08:00
parent e7ee2ed7cf
commit b2b6710a1b
4 changed files with 191 additions and 0 deletions

View File

@@ -33,3 +33,15 @@ type QueueNode[T any] struct {
func NewQueueNode[T any](value T) *QueueNode[T] {
return &QueueNode[T]{value, nil}
}
// TreeNode is node of tree
type TreeNode[T any] struct {
Data T
Left *TreeNode[T]
Right *TreeNode[T]
}
// NewTreeNode return a TreeNode pointer
func NewTreeNode[T any](data T) *TreeNode[T] {
return &TreeNode[T]{data, nil, nil}
}