feat: add BSTree which is binary search tree

This commit is contained in:
dudaodong committed 2022-02-21 16:48:27 +08:00
1 parent e7ee2ed7cf
commit b2b6710a1b
4 files changed
+191

No files matched your search

+12
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}
}