sort

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 0 Imported by: 0

README

Sorting Algorithms

Merge Sort

The mere sort algorithm was inspired by this example.

pseudo code
 split each element into partitions of size 1
 recursively merge adjacent partitions
   for i = leftPartIdx to rightPartIdx
     if leftPartHeadValue <= rightPartHeadValue
       copy leftPartHeadValue
     else: copy rightPartHeadValue; Increase InvIdx
 copy elements back to original array

Documentation

Overview

Package sort uses the merge sort algorithm. The runtime of merge sort is at best, at worst, and at average always O(n * logn)

See https://visualgo.net/en/sorting for a visual example of merge sort.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data []int

func MergeSort

func MergeSort(d Data) Data

MergeSort takes the provided data (slice of int) and applies the merge sort algorithm, to sort the data.

Jump to

Keyboard shortcuts

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