Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( python ) TASK 1 ( 2 0 points ) : Implement the quick _ sort Function, you can reference the code on slides of

(python) TASK 1(20 points): Implement the quick_sort Function, you can reference the code on slides of advanced sorting algorithms
# Run the code to make sure it is working
a_list =[54,26,93,17,77,31,44,55,20]
quick_sort(a_list)
print(a_list)
# Task 2(30 pts): Modify the partition function, instead of using first element of list as pivot
# You will change to choose the last element of list as pivot
# In the test code, you will create a seperate list ** b_list** and fill in the b_list with 24 random values from range(1,100), so the 24 elements in b_list is from 1 to 99 inclusive
# Print the b_list before sorting
#Use the new version of quick_sort (pivot will be last element of list) to sort the b_list and print it out
b_list=
print(b_list)
quick_sort(b_list)
print(b_list)
# Task 3(50)
# Based on the partition function, created another partition_median, you will apply the algorithm
# Choose the pivot as the median of three on pg.41-43
# Create functions: quick_sort_median and quick_sort_median_helper that call partition_median inside
# Test your functions with random generated list, size 24
c_list=
print(c_list)
quick_sort_median(c_list)
print(c_list)
TASK 1(20 points): Implement the quick_sort Function, you can reference the code on slides of advanced sorting algorithms
# Run the following code to make sure it is working
a_list =[54,26,93,17,77,31,44,55,20]
quick_sort(a_list)
print(a_list)
# Task 2(30 pts): Modify the partition function, instead of using first element of list as pivot
# You will change to choose the last element of list as pivot
# In the test code, you will create a seperate list ** b_list** and fill in the b_list with 24 random values from range(1,100), so the 24 elements in b_list is from 1 to 99 inclusive
# Print the b_list before sorting
#Use the new version of quick_sort (pivot will be last element of list) to sort the b_list and print it out
b_list=
print(b_list)
quick_sort(b_list)
print(b_list)
# Task 3(50)
# Based on the partition function, created another partition_median, you will apply the algorithm
# Choose the pivot as the median of three on pg.41-43
# Create functions: quick_sort_median and quick_sort_median_helper that call partition_median inside
# Test your functions with random generated list, size 24
c_list=
print(c_list)
quick_sort_median(c_list)
print(c_list)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions