Coder Social home page Coder Social logo

algorithmexercises's Introduction

Algorithm Exercises

Currently implemented algorithms

  • Heapsort
    • Heapify-down implemented as non-recursive
  • Quicksort
    • Uses the Hoare partition scheme
    • Uses median-of-three pivot selection
  • Insertion sort
  • Introsort
    • Using C++ STL implementation
    • Quicksort is performed to a maximum depth given by 2×log2(n), then heapsort is done on any list longer than 16, finally an insertion sort pass
  • Bogosort
    • Random & permutation methods implemented
    • Removed from test/timeTest.cpp as it is horribly slow
      • Using random input of length n made of random numbers generated in the range [a,b], the expected number of iterations is (b-a+1)^n / ((b-a+1)+n choose (b-a+1))
      • Ex. length=100 & range=[1,10], expected number of iterations is 10^100 / (110 choose 10) which equals 2.13 × 10^96
  • Bubble sort
  • Merge sort
    • Implemented using a bottom-up approach (non-recursive)
    • Main merge method uses no more than n/2 extra space
    • In-place merge method also implemented just in case memory is a concern
      • Speed degrades to O(n^2)
  • Selection sort
  • Timsort
    • Uses specialized merge (galloping)
  • Patience sort
    • Uses MergeSort's merge
    • Binary search to find proper pile

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.