Data Structures and Algorithms — Homework 5

Due by 11:59pm Wednesday, February 28

Reading

Programming Exercises

  1. Finish the exercises from Lab 5 and submit the following class definitions:

    Person.java, MyRectangle.java, PersonStack.java

  2. Using two ArrayList<String> objects, write a program called Cities that generates ten random permutations (orderings) of your ten favorite cities or towns. To generate each permutation, first initialize one ArrayList with the city names, then repeatedly remove cities at random from it and add them to the other ArrayList. Finally, print out the second ArrayList. For example, the first few lines of output of your program might look something like this:

    Permutation #1
    [Bronxville, Key West, Santa Fe, Atlanta, Tulsa, San Francisco, Bloomington, Ithaca, Portland, Manhattan]
    Permutation #2
    [Portland, Atlanta, Tulsa, Bronxville, Bloomington, Key West, Santa Fe, Manhattan, Ithaca, San Francisco]
    Permutation #3
    [Santa Fe, Tulsa, Key West, Portland, San Francisco, Ithaca, Bloomington, Bronxville, Manhattan, Atlanta]
    ...
    


Turning in Your Homework

Files to submit:

Submit the above files using the Homework Upload Site. Please include your name and the assignment number in a comment at the top of each Java source code file. You DO NOT need to submit your compiled .class files or any other files.

If you have questions about anything, just ask!