binarytree

package
v0.0.0-...-e90a610 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InOrderTraverseIterative

func InOrderTraverseIterative(node *Node) []int

func InOrderTraverseRecurive

func InOrderTraverseRecurive(node *Node) []int

func POT

func POT(node *Node) []int

func PostOrderTraverseIterative

func PostOrderTraverseIterative(node *Node) []int

func PostOrderTraverseRecurive

func PostOrderTraverseRecurive(node *Node) []int

func PreOrderTraverseIterative

func PreOrderTraverseIterative(node *Node) []int

func PreOrderTraverseRecurive

func PreOrderTraverseRecurive(node *Node) []int

Types

type Heap

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

type IHeap

type IHeap interface {
	// swap with parent if unordered
	MoveUp()
	// swap with child if unordered, aka. heapify
	MoveDown()

	// push at the end, then use MoveUp() to re-heap
	Push()
	// remove at the front, move last node to front, then use MoveDown() to re-heap
	Pop()

	// remove any node
	// swap it with last node
	// if it's child out of order, use MoveDown()
	// if it's parent out of order, use MoveUp()
	Remove(interface{})

	// keep calling Push() to turn an unordered array to a heap
	Build()
}

type Node

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

func Insert

func Insert(node *Node, value int) *Node

Jump to

Keyboard shortcuts

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