Coder Social home page Coder Social logo

go-sort's Introduction

Go Sort

Overview

This Repo shows different sorting algorithms implemented in Golang.
Every sorting algorithm is packed into its own folder and loaded into main. I also created a benchmark file. Don't run the entire file at once, it will fail due to the 11 minutes limit.

The main package does implement call for every package that in this module:

  1. Array of, 100000 random integers between 0 and 9223372036854775807 (math.MaxInt)
  2. Copy the created array, run Insertion Sort and measure the time it takes to sort the array
  3. Copy the created array, run Bubble Sort and measure the time it takes to sort the array
  4. Copy the created array, run Shell Sort and measure the time it takes to sort the array
  5. Copy the created array, run Quick Sort and measure the time it takes to sort the array
  6. Copy the created array, run Merge Sort and measure the time it takes to sort the array
  7. Copy the created array, run the sorting algorithm build into go sort (from sort pkg) and measure the time it takes to sort the array
  8. Copy the created array, run Slice Sort (from golang.org/x/exp/slices) and measure the time it takes to sort the array

Benchmark and Unit Tests

Benchmark

The benchmark file ./main_test.go does the same, but run with the input cases:

Warning

For some sorting algorithms It's impossible to get a successful run (e.g. Bubble Sort)!

  1. 10
  2. 100
  3. 1000
  4. 10000
  5. 100000
  6. 1000000
  7. 10000000
  8. 100000000

Unit Tests

Under the intense scrutiny of unit tests, each sorting algorithm unveils its intricate dance. The way they align, correct and reorder data โ€“ it's like a performer on a stage, demonstrating their meticulously rehearsed act. Each test is a critical audience, assessing the show and ensuring that the performance is flawless. Change the routine? The unit tests won't miss any missteps. Adapting this practice transforms your routine code into a dynamic spectacle, elegantly flowing in the theater of your software. In turn, every line of code is now part of a thrilling performance, each playing a pivotal role in keeping the audience, which is your software system, captivated.


Codesandbox

You can run this Repo in Codesandbox!

Edit in CodeSandbox


Commands to run

run main.go

go run cmd/go-sort/main.go

run unit test

go test -v tests/main_test.go

run benchmark

go test -bench=. tests/main_test.go

go-sort's People

Contributors

hra42 avatar mookth789 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.