Giter Site home page Giter Site logo

sortalgorithmanalysis's Introduction

© Reese Barnett

Multi-Sort Analysis

Note: Timings carried out on a MacBook Pro (15-inch, 2019) with 2.3GHz 8-Core Intel Core i9 CPU and 16GB of 2400 MHz DDR4 memory.

Purpose

Why are there so many algorithms for the same task? Algorithms vary by how quickly they run and the amount of resources they use. Two sorting algorithms can produce the same output but may vary by their runtimes, resource use, or both. An algorithm's run time and space usage is often expressed as a function of the input size, using Big O notation. The Big O notation for an algorithms runtime is called the time complexity, likewise the Big O notation for an algorithm's resource use is called the space complexity. The purpose of this project is to calculate the time complexities of Merge Sort, Heap Sort, Quick Sort, Insertion Sort, and In-Place Merge Sort with input arrays of various sizes and element orders.


Development Info

The Multi-Sort Analysis is conducted by a single developer, Reese Barnett. Barnett is responsible for all the code. This project uses an iterative development process called Agile that allows Barnett to evolve requirements and solutions over the lifetime of the application.

  • Developer(s): Reese Barnett
  • Programming Technologie(s): CLion, chrono, climits, cmake
  • Language(s): C++

Procedure

Setup

  • Each algorithm will be timed on how long it takes to sort a specific input array into ascending order. Input arrays have two attributes: size and order of elements. The size of the array, N, is the number of integers in the array. N ranges from 2,000 to 30,000 (inclusive) by 2,000 increments. The order of the elements in the input array can be random, sorted (ascending order), and reverse sorted (descending order).

Execution

  • All five sorting algorithms are tested on the same 45 distinct input arrays ({N=2,000 , Random}, {N=2,000 , Sorted}, ... , {N=30,000 , Reversed}). This means the input array with 22,000 integers in random order is the same array that all five sorting algorithms will be tested on. The sorting algorithms will sort an input array 10 times and the average time will be recorded.

Results

Merge Sort

Heap Sort

Quick Sort

Insertion Sort

In Place Merge Sort


Analysis

From the data collected Barnett concluded:

Merge Sort:
Random Sorted Reverse
O(nlog(n)) O(nlog(n)) O(nlog(n))
Heap Sort:
Random Sorted Reverse
O(nlog(n)) O(nlog(n)) O(nlog(n))
Quick Sort:
Random Sorted Reverse
O(nlog(n)) O(n2) O(n2)
Insertion Sort:
Random Sorted Reverse
O(n2) O(n) O(n2)
In Place Merge Sort:
Random Sorted Reverse
O(n2) O(nlog(n)) O(n2)

sortalgorithmanalysis's People

Contributors

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