HeapSort

package
v0.0.0-...-988b5a2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 0 Imported by: 0

README

Heap Sort

Heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an nsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum.

Algorithm Visualization

Complexity

Name Best Average Worst Memory Stable
Heap sort n log(n) n log(n) n log(n) 1 No

References

Wikipedia

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap struct{}

func (*Heap) BuildHeap

func (heap *Heap) BuildHeap(array []int)

BuildHeap : Build heap from array

func (*Heap) HeapSort

func (heap *Heap) HeapSort(array []int) []int

func (*Heap) Heapify

func (heap *Heap) Heapify(array []int, root, length int)

Heapify : Heapify array

func (*Heap) Left

func (*Heap) Left(root int) int

func (*Heap) RemoveTop

func (heap *Heap) RemoveTop(array []int, length int)

func (*Heap) Right

func (*Heap) Right(root int) int

Jump to

Keyboard shortcuts

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