Sunteți pe pagina 1din 3

http://cs.bilgi.edu.

tr

Comp 231 / Cmpe 211 Worksheet (Week 06)


CMPE 211 assignment Classwork
For all our exercises this week we will assume that we are sorting elements of some type x, and that we are provided with a comparison function for these elements of type x to determine which should come rst in any sorted order. In object oriented languages, the objects to be sorted will usually have a comparison method as a member (Java). This week you need to check that you have working versions of insert sort, merge sort, heapsort and quick sort for arrays in some programming language. That is a total of four working sort programs. These should be implemented in Java. (a) Write a series of tests and test data to check that each of your sort programs works on all of the following cases, at a minimum; a list of just one element, an in order list of two elements, an out of order list of two elements, an in order list of 100, 1000, 10000 elements, a reverse order list of 100, 1000, 10000 elements, a random order list of 100, 1000, 10000, 100000, 10000000 elements. The random order tests of length 100000 and 1000000 elements need only be done for merge and quick sort - insert sort will take too long. You will need to write functions to generate the necessary test data, and to run the tests (you need to use the computer to repeat routine tasks) and you have already been asked to write a function to check that the results are actually in order. You will need to revise and complete this work. From each of your programs you should be able to get enough data to graph sorting time for each of your four sorting implementations against input sizes 100, 1000, 10000, 100000, 1000000 for in order, reverse order and random order inputs. (b) You may not be able to complete all this work in class. Use your class time productively to solve your big problems so that you can complete the work at home.

Document last compiled on November 11, 2013

http://cs.bilgi.edu.tr

You will be assessed on the quality of your code, which should include data denitions, contracts, statements of purpose and on the quality of your test data. You should submit a written record of what you did and the results you got to the assistant at the end of the class.

Reading - to be completed by 18 November


Revise Cormen Chapters 1, 2, 3, 4.4 and 7 and read, for the rst time, Chapter 6.

Project 03
Deadline: 0900 Wednesday, November 25

Irrelevant code will be penalised1 in project submissions.

Work at home
Before anything else you are required to complete and correct your class work so all the programs work correctly. (a) Complete the class work to obtain fully tested versions of all your 4 sorting programs. (b) Produce the test and timings. (c) Graph the times for sorts of arrays and linked lists of various sizes against the size of the array or linked list. You can use a spreadsheet to process your data conveniently. If T is the time taken for each sort, and n is the number of elements in the array being sorted, plot lg n on the x-axis and T on the y-axis. Comment n on any dierence in the shape of the curves that you observe. (d) Your project submission should include all your code, your test data, test results, graphs and a report on what you did and what you learnt. You will need to use a suitable program to combine and compress these into a single le in .tar.gz format. Free programs are available to so this job for all major operating systems. Please use your initiative.
Document last compiled on November 11, 2013

http://cs.bilgi.edu.tr

You are free to take your projects to the assistants before the deadline to check their acceptability. You will need to start trying to nd the assistants early. I could not nd an assistant to check my project is not an excuse. The class hours may be a good time to nd them. To be acceptable a project must run and must perform the specied task. It must, at minimum, include test data that exercises all the code with complete coverage. It must include sample inputs and output and comments on the working of the code. Apart from the basic functions we have worked on in the lectures, we will expect all project submissions to be dierent and copies will result in failure of the course.

Deadlines
Deadline:. Do not forget report and screenshots. Submission of 70% of projects is required to pass the course. To be counted as a submission, your program must compile and run and be your own work. Assessors decision is nal.

Document last compiled on November 11, 2013

S-ar putea să vă placă și