Pure Programmer
Blue Matrix


Cluster Map

Project: Quicksort

The [[Quicksort]] one of the most efficient sorts. It was first introduced by [[Tony Hoare]] in 1959. It can be implemented very easily using recursion. Write a function that takes a list of integers and sorts the list, in place, using a Quicksort. Test the function by creating a random list of integers, print the random list, sort the list, then print out the sorted list. Accept the number of integers to put in the list and the maximum integer to randomly generate on the command line. What is the worst case performance of the Quicksort?

Output
$ python3 Quicksort.py 10 10 Random List [7, 8, 9, 5, 6, 7, 6, 6, 4, 4] Sorted List [4, 4, 5, 6, 6, 6, 7, 7, 8, 9] $ python3 Quicksort.py 20 100 Random List [85, 77, 96, 69, 94, 18, 30, 22, 21, 86, 17, 16, 22, 10, 99, 42, 76, 34, 16, 75] Sorted List [10, 16, 16, 17, 18, 21, 22, 22, 30, 34, 42, 69, 75, 76, 77, 85, 86, 94, 96, 99]

Solution