Lab 4 - Sorting Arrays Activity Sheet Student's Name Exercise 1: Suppose that Bubble Sort is applied to the following list of numbers: 73 21 15 83 66 7 19 18 Show what the list will look like after each phase in the sort: Exercise 2: Suppose that Selection Sort is applied to the list of numbers given in Ex.1. Show what the list will look like after each phase in the sort: Exercise 3: Suppose that Insertion Sort is applied to the list of numbers given in Ex.1. Show what the list will look like after each phase in the sort: Exercise 4: Bubble sort, Insertion sort, and Selection sort are order N^2 algorithms. You should be able to use data you collected in this lab to compute the value of K in the equation T = K*N^2 for each of these sorts. (Recall that N is the array size and that T is the time it takes to sort one array of size N. Also remember that the equation is only approximately true). Make a table showing the following information for each array size, N, for which you collected data: the array size (N); the number of arrays you sorted; the total computation time to sort the arrays; the computation time for one array (T); and the computed value T/(N*N) which is an approximation for K. Based on the data in your table, what is your best guess for the actual value of K? Explain your reasoning. +-------------------------------------------------------------------------+ | Array size N | Number of |Compute time to| T = Average |K = T/N^2| | (Bubble sort) |Arrays to sort|sort all arrays|compute time to| | | | | |sort one array | | |----------------+--------------+---------------+---------------+---------| | 1000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 5000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 10000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 15000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 20000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 25000 | 10 | | | | +-------------------------------------------------------------------------+ +-------------------------------------------------------------------------+ | Array size N | Number of |Compute time to| T = Average |K = T/N^2| |(Selection sort)|Arrays to sort|sort all arrays|compute time to| | | | | |sort one array | | |----------------+--------------+---------------+---------------+---------| | 1000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 5000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 10000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 15000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 20000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 25000 | 10 | | | | +-------------------------------------------------------------------------+ +-------------------------------------------------------------------------+ | Array size N | Number of |Compute time to| T = Average |K = T/N^2| |(Insertion sort)|Arrays to sort|sort all arrays|compute time to| | | | | |sort one array | | |----------------+--------------+---------------+---------------+---------| | 1000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 5000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 10000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 15000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 20000 | 10 | | | | |----------------+--------------+---------------+---------------+---------| | 25000 | 10 | | | | +-------------------------------------------------------------------------+ Exercise 5: Consider the data that you collected on the compute time of the three sorting algorithms. For arrays of size 10000, how do the algorithms rank according to speed? How about for arrays of size 50000?