8000 GitHub - ncruces/sort: Sorting algorithms implemented in Go
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ncruces/sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting algorithms

Go Reference Go Report Go Coverage

Sorting algorithms implemented in Go.
Use as a learning resource.
Clarity and simplicity, not so much performance, are the goals.

Quicksort

The most interesting (and more practical) algorithm here is Tony Hoare's Quicksort. It's relatively fast, only slightly slower than the standard library on the average case. It's flexible, and gives you asymptotically optimal algorithms for median finding, top-K, etc (which the standard library lacks).

quicksort visualization

This version avoids quadratic behavior by using median-of-ninthers when a bad pivot is detected:

median-of-ninthers visualization

The algorithm is fully deterministic, and every step contributes to partially sorting the array.

Heapsort

An implementation of Floyd's bottom-up Heapsort.

heapsort visualization

Shellsort

An implementation of Shellsort with Tokuda's sequence.

heapsort visualization

Credits

Visualizations thanks to: github.com/invzhi/sorting-visualization

About

Sorting algorithms implemented in Go

Resources

License

Stars

Watchers

Forks

Languages

0