Skip to content

Instantly share code, notes, and snippets.

@tef
Created November 9, 2013 12:30
Show Gist options
  • Save tef/7384949 to your computer and use it in GitHub Desktop.
Save tef/7384949 to your computer and use it in GitHub Desktop.
possible assignments:
- add tests to check the behaviour is correct.
don't compare it to python's output, just check that each element is greater than the
next, with the compare function
- add profiling code, and run it with much, much larger lists ~5000 elements
which one is fast, slow?
- quick sort picks a random pivot, is this a good choice? what happens on larger lists
does the time vary? what happens if you take a bunch of points (top, middle, bottom)
and use an average of them to split the array into two lists
- quicksort can be done in-place, without creating extra lists. can you write a new
quicksort that doesn't create temporary arrays:
hint: your quicksort will take three arguments, the array, and the range to sort within
i.e qsort_inplace(array, lo, hi) where you only sort x where lo <= x < hi, and do
qsort_inplace(array, 0, len(array)) to begin with
- make the merge sort smarter when splitting lists, this is called "adaptive merge sort"
i.e split the list into ascending and decending sequences and merge them
- fill up the hash table with entries (it only has 8 buckets), what happens, do the entries
split evenly amongst the buckets, or does one bucket get really big. what happens
to the performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment