package binary
import "github.com/shuLhan/share/lib/mining/tree/binary"
Package binary contain implementation of binary tree.
Index ¶
- type BTNode
- func NewBTNode(v interface{}, 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 interface{} }
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.53.1 (latest)
- Published
- Mar 2, 2024
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 5 days ago –
Tools for package owners.