CSU Long Beach
CECS 274
Programming and Problem Solving II


Syllabus
Schedule
Grading
Project 1
Project 2
Solution to Project 2
Project 3
Solution to Project 3
Project 4
Solution to Project 4
Project 5
Set Solution to Project 5
Map Solution to Project 5
Lecture Notes
Basic Unix Commands
Basic vi Commands
More vi Commands
Using Eclipse
Compiling and Running Java on Unix


Mimi Opkins Home

Project 3

Assignment

  • A Scavenger Hunt is a party game that people play in teams. They are given a list of items to find throughout the surrounding neighborhood. Our challenge is to find the best data structure to store the results of the hunt.
  • Create a list of 100 items that you might have people find on the hunt. These should be items that they have a chance of finding through out the neighboorhood. For example, yesterday's newspaper, a shoelace, a paperbag,.... Load the list anyway you want (console input, flatfile, etc.)
    • You will run the program two times, once using a set of ArrayLists, and once using a set of LinkedLists. Our pupose is to find the more efficient data structure to use for a scavenger hunt.
    • Ask the user how many teams will play the game. Create this number of teams. For each team load all of the items from the list. Shuffle the list after loading the items each time. Find the total time it takes to add the items to all of the teams.
    • Ask the user what position in the list to be used for retrieving and inserting elements. Retrieve that element from each of the teams. Find the total time it takes.
    • Next insert a new element at that position in each of the lists. Find the total time it takes.
    • Use the Random class to generate a number between 0 and the 100. Find the element in the scavenger hunt list at that position. Retrieve that element from each of the lists. Find the total time it takes.
    • Display the time in milliseconds for each of these operations.
    • Run the program several times with different input values and see how it affects the output.
  • Write a brief analysis of your findings along with your recommendations.
  • Make sure you use appropriate exception handling. This would be related to how you initially set up the list of items for the scanvenger hunt and how you have the user enter the valus for the number of teams and the element to work worth.
  • Make sure you document the program as specified in the grading guidelines. Document the methods describing their purpose, input and output.
  • You will hand in a printout of the program(s), sample output and a UML class diagram along with a demo in the lab.
  • The following code snippet will help with the timing
    Date today = new Date();
    long time1, time2;
    time1=System.currentTimeMillis();
    .
    .
    .
    .
    time2=System.currentTimeMillis();
    System.out.println("Time for the operation is: " + (time2-time1));
    

Grading Criteria

    You will be graded on the following components:
  • Does the program do what is required
  • Is it properly documented
  • Is it fully tested
  • Is it properly designed