binarytree

package
v0.0.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessNodesByLayer

func AccessNodesByLayer(root *Node) [][]int

AccessNodesByLayer Function that access nodes layer by layer instead of printing the results as one line.

func InOrder

func InOrder(n *Node)

InOrder add's children to a node in order left first then right recursively

func LevelOrder

func LevelOrder(root *Node)

LevelOrder LevelOrder

func Max

func Max(a, b int) int

Max Function that returns max of two numbers - possibly already declared.

func PostOrder

func PostOrder(n *Node)

PostOrder PostOrder

func PreOrder

func PreOrder(n *Node)

PreOrder Preorder

Types

type BTree

type BTree struct {
	Root *Node
}

BTree Returns a binary tree structure which contains only a root Node

func (*BTree) Depth

func (t *BTree) Depth() int

Depth returns the calculated depth of a binary tree

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node structure for Nodes

func BstDelete

func BstDelete(root *Node, val int) *Node

BstDelete removes the node

func InOrderSuccessor

func InOrderSuccessor(root *Node) *Node

InOrderSuccessor Goes to the left

func Insert

func Insert(root *Node, val int) *Node

Insert a value in the BTree

func NewNode

func NewNode(val int) *Node

NewNode Returns a new pointer to an empty Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL