Sie sind auf Seite 1von 3

http://cs.bilgi.edu.

tr

Comp 231 / CMPE 211 Worksheet (Week 01/02)


1 Revised Version

Because we were unable to run the lab classes in the rst week of term, due to lack of a teaching assistant, the worksheet has been revised to take account of the material covered in the lecture. The submission date for the project has been extended by one week.

Classwork
Note: We did items (a) to (c) below in the rst lecture of the course. You are free to use the denitions and code from the lecture. (a) Write a self referential data denition for a list of integers. This will be independent of any programming language. (Done in the lecture) (b) Write a self referential data denition for a sorted (in ascending order) list of integers. Hint: you will get into diculties if you allow an empty list to be a sorted list. Avoid that trap in your denition. This will also be independent of any programming language. (Done in the lecture) (c) In any programming language of your choice (but preferably Java), specify the contract for, give examples for, produce a template for, and nally code a function/method/procedure that consumes a list of integers and produces true if the list is a sorted list as dened above and false if it is not. (Done in the lecture) (d) Using (preferably) the Eclipse development environment and the Java programming language, setup a series of JUnit tests to test the isSorted method, written in the lecture. (e) Using the same design process produce a function that consumes an integer and a sorted list and produces a sorted list with the provided integer inserted into the list. Values may be duplicated in the list.
Document last compiled on October 6, 2013

http://cs.bilgi.edu.tr

(f) Set up and use JUnit tests to test this method. (g) Using the same design process and the helper function/methods you have developed produce a function that consumes a list of integers and produces a sorted list of integers. (h) Set up and use JUnit tests to test this method. (i) Test your programs in the lab. Write up your results. 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. Record your interactions in a le. Your work will be graded on the spot.

Reading
Cormen Chapters 1, 2 and 3.

Project 01
Deadline: 0900 Monday, October 14

Irrelevant code will be penalised1 in project submissions. Before anything else you are required to complete and correct your class work so all the programs work correctly. If you fail to do this, your project will be treated as unacceptable. (a) Complete the class work to give a fully tested version of your insertion sort for lists of integers. (b) Set up a test environment for your insertion sort program that allows you to generate large random arrays of many dierent sizes, and to time the sorting process. You will need to go up to arrays with hundreds of elements to get signicant times.
Document last compiled on October 6, 2013

http://cs.bilgi.edu.tr

(c) You will have a problem with your program after you make arrays of more than a few hundred elements. What is the problem? (d) Graph the times for sorts of arrays various sizes against the size of the array. 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, T plot n on the x-axis and n 2 on the y-axis. Comment on any dierence in the shape of the curves that you observe. The acceptable project policy will apply in this course. To obtain any coursework mark at all, all projects from now on must have been submitted to an acceptable standard. No subsequent project will be accepted until all its predecessors have been accepted. Unacceptable projects may be resubmitted, but will only get 50% marks in the rst week after the deadline, 33% marks in the second week after the deadline and so on. 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. The project description is very open ended. There are lots of dierent ways it can be completed. So 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: 0900 2009-10-14 (Monday morning!). 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 October 6, 2013

Das könnte Ihnen auch gefallen