Problem Set 8¶
Problem 8.1
Create a bubblesort function called “bubblesort(list)” which takes a list as input and outputs the same list, sorted. Use [3,7,15,9,4,11,1,5,2]
as a test input. How many iterations are required to sort this list?
Hint: see the “Class 10” module
Problem 8.2
Create a mergesort function called “mergesort(list)” which takes a list as input and outputs the same list, sorted. Use [3,7,15,9,4,11,1,5,2]
as the test input. How many iterations are required to sort this list? Compare the number of iterations of mergesort to bubblesort.
Hint: see the “Class 10” module