Question: **in python please** Modify the quicksort function so that it calls insertion sort to sort any sublist whose size is less than 50 items. Compare

**in python please**

Modify the quicksort function so that it calls insertion sort to sort any sublist whose size is less than 50 items. Compare the performance of this version with that of the original one, using data sets of 50, 500, and 5,000 items. Then adjust the threshold for using the insertion sort to determine an optimal setting.

Use pythons time module to calculate the duration of the original quicksort version and the modified version. Do this for 3 different data sets of 50, 500, and 5000 items. These datasets are not going to be provided, so you have to come up with them. You can use pythons random module to help come up with the random item. Experiment with a different threshold value for the size of the sublist that indicates a switch to insertion sort, and report which value was optimal.

Here is quicksort function, with indents and copyable:

Thank you!!

**in python please** Modify the quicksort function so that it calls insertionsort to sort any sublist whose size is less than 50 items.

def quicksort(lyst): quicksortHelper(lyst, 0, len(lyst) - 1) def quicksortHelper(lyst, left, right): if left

# Earlier definition of the swap function goes here import random def main(size = 20, sort = quicksort): lyst = [] for count in range(size): lyst.append(random.randint(1, size + 1)) print(lyst) sort(lyst) print(lyst) if name == " main ": main()

\#Earlier definition of the swap function goes here import random def main(size =20, sort = quicksort): lyst=[] for count in range(size): lyst.append(random. randint(1, size +1 )) print(lyst) sort(lyst) print(lyst) if name =" main ": main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!