Sie sind auf Seite 1von 1

Data Structures & Algorithms Assignment #1 Matthew Carlberg Due Next Class In the folder Dropbox > Python

Resources > Data Structures, you will find a file called sortCompare.py. This Python file contains the following: makeRandomCode(n, maxNum): Returns a random list of n numbers with the largest possible number being maxNum. 2. Three sorting functions: insertionSort, adaptiveMergeSort, and quickSort. Do the following in a Python script: 1. Collect timing data for how long it takes each of the three sorting functions to perform 1000 sorts for various values of n. Every time you sort, you should use the makeRandomCode function to create a random list with maxNum set to 1000. Then you should sort the list using the proper function call. You will need to test n = 5, 10, 20, 50, 100, 500. Do the following by hand or with a word processor/spreadsheet. You will be handing it in: 1. Make a table with your timing data. The rows of the table will be the three sorting algorithms, and the columns of the table will be n = 5, 10, 20, 50, 100, 500. 2. Plot your data with n on the x axis and time on the y axis. You should have three total graphs, one for each of the three sorting functions. 3. Which sorting function would you use if you had to sort a list with 1,000,000 items. Justify your answer with at least one. 1.

Das könnte Ihnen auch gefallen