Skip to content

peterchu999/sorting-experiment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Comparison Between Sorting Algorithm (with Go)

My Post

Checkout my post on dev.to: https://dev.to/peterchu999/sorting-algorithm-theory-vs-implementation--40ga/

Thought

By theory bubble sort would had the n^2 complexity, and the rest (merge,quick,built-in sort func) would had n*log(n) complexity. here is the graph example :

Theory Sorting Visulization

but when I implemented all of the sorting algorithm in golang, here is the graph for 300 array length test:

Sorting Algorithm Visualization

Combined Sorting Algorithm Vis

Let see closely on the first 50 random array sorting benchmark. We could see up to ~25 array size, bubble sort perform better than merge and built-in sort. However, based on the theory it aren't suppose to be. Here os the graph comparison

Theory Sorting Visulization 50 Size array

Combined Sorting Algorithm Vis with 50 array

Wierd isn't it ? but when we see the bigger picture the theory would align with the implementation. Let see the on 1000 array size

Theory Sorting Visulization 1000 Size array

Combined Sorting Algorithm Vis with 1000 array

Sorting Algorithm Visualization

Running Workflow

  • ./run-all.sh [n], change [n] with the number of max array size for benchmark

Running Python Visualization

  • pip install -r requirements.txt
  • python main.py

Running Golang Sorting

  • run the main executable
  • go run main.go

Code Taken From

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published