package binary
import "git.sr.ht/~shulhan/pakakeh.go/lib/mining/tree/binary"
Package binary contain implementation of binary tree.
Index ¶
- type BTNode
- func NewBTNode(v any, l *BTNode, r *BTNode) (p *BTNode)
- func (n *BTNode) SetLeft(c *BTNode)
- func (n *BTNode) SetRight(c *BTNode)
- func (n *BTNode) String() (s string)
- type Tree
Types ¶
type BTNode ¶
type BTNode struct { // Left branch of node. Left *BTNode // Right branch of node. Right *BTNode // Parent of node. Parent *BTNode // Value of node. Value any }
BTNode is a data type for node in binary tree.
func NewBTNode ¶
NewBTNode create new node for binary tree.
func (*BTNode) SetLeft ¶
SetLeft will set left branch of node to 'c'.
func (*BTNode) SetRight ¶
SetRight will set right branch of node to 'c'.
func (*BTNode) String ¶
String will convert the node to string.
type Tree ¶
type Tree struct { // Root is pointer to root of tree. Root *BTNode }
Tree is a abstract data type for tree with only two branch: left and right.
func NewTree ¶
func NewTree() *Tree
NewTree will create new binary tree with empty root.
func (*Tree) String ¶
String will print all the branch and leaf in tree.
Source Files ¶
- Version
- v0.60.0 (latest)
- Published
- Feb 1, 2025
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 9 hours ago –
Tools for package owners.