Git Product home page Git Product logo

quicksort-test's Introduction

quicksort-test's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

quicksort-test's Issues

Do not swap the same index with itself

The current implementation always swaps pivot_elem with i_elem, but that is a waste of computations, if they are the same. We can decrease the number of swaps (and with it the running time), if we only swap, when it indeed may change the array.

Add missing unit tests

There are currently only 3 unit tests in test/, which do obviously not cover all interesting cases. Furthermore, we use unit tests in this project to get as close to verifying our algorithms without using an actual proof assistant.

Add as many missing test cases that you can think of; this also includes any cases currently covered, but not satisfiably so.

Add alternative choices of pivot

Currently we hardcode the choice of pivot to be high_idx. Yet, we would like to support other strategies for picking the pivot that are better in practice. It is important to notice, that the partitioning procedure as per Lomuto requires the pivot element to reside at high_idx before starting the partition step.

The pivot strategies we want to support are:

  • Pick the element at high_idx. Notice, that this is an O(N2) solution for sorted (and reversely sorted) inputs.
  • A simple improvement to the above is the median of 3 pivot.
  • An even better solution is to pick the pivot as the median of 1 up to 5 randomly sampled entries from the array.

We want to support all versions simultaneously, so we need to use policies to change the behaviour of the pivot derivation.

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.