


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Data Structures and Algorithms; Subject: Computer Science; University: Illinois Institute of Technology; Term: Spring 2009;
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



In this lab you will code some of the basic functions for a singly linked list, and write tests to verify that they work correctly.
Your objectives for this lab:
Run git pull on your working copy, and you will find that the staff have added a directory called linked-list-lab, which in turn contains three files.
LinkList.java This is the main file, where your class definition will live.
TestLinkList.java This is the JUnit test file.
Makefile This contains the compiling and testing scripts.
Your job is to add a few functions, and the test cases necessary to verify them. It is highly recommended that you write the JUnit tests before writing these methods! To do this, write a stub function in LinkList.java that returns some- thing of the correct type, and then add your test function. Once it compiles and runs, commit the files to your repository. After that, start writing the method.
size returns the size of the list
Inputs none Output an integer
Actually, this is already written for you. Sort of. It has a bug, but it will not show up until later. Don’t fix the bug just yet, leave it in there so you know that your tests are working.
insert place an element at the front of the list
Inputs E data — the element to add Output none
Once you’ve added this, you can update the testSize test to see how size works when you add things to it. You can fix that bug now. So far, you do not have any way of telling whether or not insert is working, but you can test that the size of the list is being updated correctly, and you should. But to really test it you will have to assume that find has been written. So, your tests should verify insert, size, and find simultaneously. What should you test?
find returns the location of an element within the list
Inputs E data Output int — the location of the element in the list. 0 not found 1,2,... first element, second element, ...
Use the .equals method to check for equality, not ==.
Linked Lists 4 HANDING IN
4 Handing In
To hand in your code, commit your final changes to the repository, and push the results to the server. We will test your code with our own JUnit tests. We will also test your JUnit tests with several broken versions of the solutions, to make sure you did them well.