binarytree

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 0 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(root *Node) []int

Travers the tree in the following order left --> root --> right

func LevelOrder

func LevelOrder(root *Node) []int

func Max

func Max(a, b int) int

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

func PostOrder

func PostOrder(root *Node) []int

Travers the tree in the following order left --> right --> root

func PreOrder

func PreOrder(root *Node) []int

Travers the tree in the following order root --> left --> right

Types

type BSTree

type BSTree struct {
	Root *Node
}

BSTree Returns a binary search tree structure which contains only a root Node

func (*BSTree) Depth

func (t *BSTree) Depth() int

Depth returns the calculated depth of a binary saerch 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 BSTree

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