Code Monkey home page Code Monkey logo

sorting's Introduction

Sorting

You will implement the merge and quick sort algorithms.

Learning Objectives:

  1. understand how merge sort and quicksort work
  2. practice recursion
  3. practice using property-based tests

Real-world application:

Given a dataset, the first step of processing is almost always to sort the data. This allows efficient lookups via binary search, but it even makes sequential search significantly faster due to an optimization in modern CPUs called "branch prediction". (See the most upvoted stackoverflow question of all time for details.) Technical interviews therefore often require you to explain how the merge and quicksort algorithms work.

ASIDE: Recall that Python uses the TimSort algorithm. TimSort was named after the inventor [Tim Peters](https://en.wikipedia.org/wiki/Tim_Peters_(software_engineer\)), who invented it specifically for python. Tim is one of the most influential early python programmers after Python's BDFL Guido van Rossum. Besides TimSort, he is most famous for developing the Zen of Python, which is a collection of sayings describing python's guiding philosophy. You can access the Zen of Python from within python by running the command

>>> import this

In the real world, you should never implement your own sorting algorithm. The algorithms built-in to standard libraries are highly optimized by highly skilled engineers, and therefore will be much faster than anything you are likely to write.

So why are you implementing them in this assignment? The divide-and-conquer strategy used in merge/quick sort turns out to be the most fundamental tool for building your own fast algorithms, and the main purposee of this assignment is to practice this divde-and-conquer programming technique. Next week, we will explore this strategy for massively parallel data analysis of multi-terabyte twitter data. If you take CS148 (graph algorithms), you will explore many more variations of the divide and conquer technique for developing fast algorithms. Data science tasks frequently rely on matrix multiplication and the fourier transform, and the fastest versions of these algorithms are implemented via divide and conquer.

Tasks

Complete the following tasks:

  1. Fork the sorting repo and enable github actions
  2. Update the README.md file so that the test case badges point to your repo.
  3. Implement the _merged, merge_sorted, and quick_sorted functions so that all test cases in tests/test_main.py pass. You must implement merge_sorted and quick_sorted recursively.
  4. (optionally) You can receive 1 point of extra credit for implementing the quick_sort function and passing the tests in tests/test_ec.py.

Submission

Submit the link to your forked repository on sakai.

sorting's People

Contributors

mikeizbicki avatar cameronshir11 avatar axelahdritz 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.