gsv

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 8 Imported by: 0

README

GolangSortingVisualization

Codacy Badge Coverage Status Build Status Go Report Card codebeat badge

this sorting visualization is not intended to recommend any algorithm, if you need a recommendation go somewhere else.

if you like, feel free to add more Sorting Algorithm examples. Many thanks to all contributors.

Sorting Algorithms

BogoSort

Bogo Sort Animation

BubbleSort

Bubble Sort Animation

CocktailSort

Cocktail Sort Animation

CombSort

Comb Sort Animation

CountingSort

Counting Sort Animation

CycleSort

Cycle Sort Animation

GnomeSort

Gnome Sort Animation

HeapSort

Heap Sort Animation

InsertionSort

Insertion Sort Animation

MergeSort

Merge Sort Animation

OddEvenSort

OddEven Sort Animation

PancakeSort

Pancake Sort Animation

QuickSort

Quick Sort Animation

ShellSort

Shell Sort Animation

SelectionSort

Selection Sort Animation

StoogeSort

Stooge Sort Animation

HowTo

./start.sh
$ go run gsv.go --help
Usage of gsv:
  -algo="bubble": Select sorting algorithm all/bogo/[bubble]/comb/counting/gnome/insertion/oddEven/selection/sleep
  -count=30: number of values
  -fps=10: frames per second
  -max=9: highest value
  -mode=1: visualization mode
  -vis="stdout": Select output: [stdout]/gif

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Count int
View Source
var Fps int
View Source
var Max int
View Source
var Mode int

Functions

func BitonicSort added in v0.13.0

func BitonicSort(arr []int, frameGen FrameGen)

BitonicSort is an implementation of https://en.wikipedia.org/wiki/Bitonic_sorter

func BogoSort

func BogoSort(arr []int, frameGen FrameGen)

BogoSort is an implementation of https://en.wikipedia.org/wiki/Bogosort

func BubbleSort

func BubbleSort(arr []int, frameGen FrameGen)

BubbleSort is an implementation of https://en.wikipedia.org/wiki/Bubble_sort

func CocktailSort

func CocktailSort(arr []int, frameGen FrameGen)

CocktailSort is an implementation of https://en.wikipedia.org/wiki/Cocktail_shaker_sort

func CombSort

func CombSort(arr []int, frameGen FrameGen)

CombSort is an implementation of https://en.wikipedia.org/wiki/Comb_sort

func CountingSort

func CountingSort(arr []int, frameGen FrameGen)

CountingSort is an implementation of https://en.wikipedia.org/wiki/Counting_sort

func CycleSort added in v0.11.0

func CycleSort(arr []int, frameGen FrameGen)

CycleSort is an implementation of https://en.wikipedia.org/wiki/Cycle_sort

func GnomeSort

func GnomeSort(arr []int, frameGen FrameGen)

GnomeSort is an implementation of https://en.wikipedia.org/wiki/Gnome_sort

func HeapSort added in v0.10.0

func HeapSort(arr []int, frameGen FrameGen)

HeapSort is an implementation of https://en.wikipedia.org/wiki/Heapsort

func InsertionSort

func InsertionSort(arr []int, frameGen FrameGen)

InsertionSort is an implementation of https://en.wikipedia.org/wiki/Insertion_sort

func MergeSort added in v0.9.1

func MergeSort(arr []int, frameGen FrameGen)

MergeSort is an implementation of https://en.wikipedia.org/wiki/Merge_sort

func OddEvenSort

func OddEvenSort(arr []int, frameGen FrameGen)

OddEvenSort is an implementation of https://en.wikipedia.org/wiki/Odd–even_sort

func PancakeSort added in v0.12.0

func PancakeSort(arr []int, frameGen FrameGen)

PancakeSort is an implementation of https://en.wikipedia.org/wiki/Pancake_sorting

func QuickSort added in v0.9.1

func QuickSort(arr []int, frameGen FrameGen)

QuickSort is an implementation of https://en.wikipedia.org/wiki/Quicksort

func RadixSort added in v0.13.0

func RadixSort(arr []int, frameGen FrameGen)

RadixSort is an implementation of https://en.wikipedia.org/wiki/Radix_sort

func SelectionSort

func SelectionSort(arr []int, frameGen FrameGen)

SelectionSort is an implementation of https://en.wikipedia.org/wiki/Selection_sort

func ShellSort added in v0.10.0

func ShellSort(arr []int, frameGen FrameGen)

ShellSort is an implementation of https://en.wikipedia.org/wiki/Shellsort

func SleepSort

func SleepSort(arr []int, frameGen FrameGen)

SleepSort is a non-standard sorting algorithm

func StoogeSort

func StoogeSort(arr []int, frameGen FrameGen)

StoogeSort is an implementation of https://en.wikipedia.org/wiki/Stooge_sort

func WriteGif

func WriteGif(name string, g *gif.GIF)

WriteGif writes the GIF file to disk

func WriteStdout

func WriteStdout(arr []int)

WriteStdout writes the array to stdout as an ASCII visualization

Types

type FrameGen

type FrameGen func([]int)

FrameGen defines a function type for generating frames

func (FrameGen) AddFrame

func (fg FrameGen) AddFrame(arr []int)

func (FrameGen) Complete

func (fg FrameGen) Complete()

func (FrameGen) Setup

func (fg FrameGen) Setup(name string)

type GifVisualizer

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

GifVisualizer is a visualizer that outputs a GIF

func (*GifVisualizer) AddFrame

func (gv *GifVisualizer) AddFrame(arr []int)

AddFrame adds a frame to the GIF

func (*GifVisualizer) Complete

func (gv *GifVisualizer) Complete()

Complete writes the GIF to disk

func (*GifVisualizer) Setup

func (gv *GifVisualizer) Setup(name string)

Setup initializes the GIF visualizer

type Sorter

type Sorter func([]int, FrameGen)

Sorter defines a function type for sorting algorithms

type Visualizer

type Visualizer interface {
	Setup(string)
	AddFrame([]int)
	Complete()
}

Visualizer interface for visualizing sorting steps

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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