Giter Site home page Giter Site logo

vrompasa / sorting-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 100 KB

A small Python program demonstrating the runtimes of different sorting algorithms

Python 91.61% Shell 8.39%
sorting sorting-algorithms insertion-sort merge-sort quicksort heapsort

sorting-demo's Introduction

Sorting Algorithm Demo

This is a small Python program that demonstrates runtimes of common sorting algorithms. I used this project mainly to teach myself how different sorting algorithms work and how they differ.


For Windows users: Because the program includes bash commands, it will crash if run on Windows. If you wish to run it on a Windows machine, open the sorting_demo.py file and remove all the lines that use the subprocess module (lines 95, 99, 100, 101, 108, 109). This will prevent an animation from running during the sorting process.

GIF missing


How does it work?

To start the program, run the sorting_demo.py file.

First, the program asks the length of the array the user wants to sort. I limited the length to ten million because for larger values, generating the array takes too long to be practical.

Then, the user is asked in which order the array should be:

  • Ascending order - elements are in ascending order [0, 1, 2, ... length-2, length-1]
  • Descending order - elements are in descending order [length-1, length-2, length-3, ... 1, 0]
  • Randomized order - the array consists of length number of elements between 0 to 999 in random order

Finally, the user decides which of the following sorting algorithm to use:

  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort

After the algorithm finishes, the program gives the time it took to sort the array and exits.

sorting-demo's People

Contributors

vrompasa 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.