-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Divide and conquer algorithm", exercise 2 #26
Comments
#partition function
|
This recursive quicksort algorithm should work with any kind of input. Note: +++ Quicksort. +++
+++ Quicksort, Partition, and Testing Sets. +++
|
I haven't yet correctly separated the code between quicksort() and partition(), but this quicksort() that contains my partition() code does the job. Will continue trying to separate tomorrow.
|
Version of partition() and quicksort() separated:
|
Hi guys, (As in the previous exercise) That has been the most interesting discussion we had so far in the entire course. I really thank you for all you effort in solving it, providing an incredible number of different perspectives and angles to look at this problem. It has been great. Here my solution to the problem - I hope you can find it clear but I'm happy to discuss it in the next lecture. The source code is available online as usual.
|
Develop the divide and conquer algorithm
def quicksort(input_list, start, end)
that takes a list and the positions of the first and last elements in the list to consider as inputs, and that callspartition(input_list, start, end, start)
(defined in the previous exercise) to partition the input list into two slices, and then applies itself recursively on the two partitions (neither of which includes the pivot value since it has been already correctly positioned by means of the execution of partition). In addition, define appropriately the base case of the algorithm so as to stop if needed before to run the partition algorithm.Accompany the implementation of the function with the appropriate test cases.
The text was updated successfully, but these errors were encountered: