San Jose State University | CS 151 - OO Design Section 4 | Spring 2017

Homework 1 / Prerequisite Quiz

  1. Prepare a plain text file aboutme.txt with the following information:
    Your name:
    Your student ID:
    Your major:
    Your preferred email address: 
    Check one: [ ] Undergraduate, [ ] Graduate, [ ] Open university 
    Repeating the class? [ ] Yes, [ ] No
    Place and semester where you took a programming course in Java: 
    Course number and grade received:
    Place and semester where you took a course in data structures: 
    Course number and grade received:
    Time it took you to answer the two questions below:
    Did you ask anyone for help? [ ] Yes, [ ] No
    
  2. In Java, implement the method Lists.swapLargestAndSecondSmallest(ArrayList<Integer> a) that swaps the largest and second smallest element in a. If there are multiple largest or second smallest elements, pick the first one. If all elements are the same, don't change anything. Your algorithm should be O(n). Check your answer with CodeCheck
  3. Implement the method Encoding.morseCodes(int m, int n) that yields a set of all Morse code strings with m dots and n dashes. For example, morseCodes(2, 1) yields a set with ..- .-. ..- -.. in some order. Hint: Recursion. Start with a dot, and then what? Start with a dash, and then what? Check your answer with CodeCheck

Important: The point of this assigment is for you to demonstrate that you already know how to program. This is not a class for students who can't yet program. Do not ask anyone for help. If you need to ask someone for help, or if it takes you longer than an hour to do this assignment, do not take this class. Take CS46A/B instead.

Important: Make sure your code passes CodeCheck. In particular, that means that you must use no package declarations!

Important: Make a Git repo for all your work in this class. Put your work for this homework into a folder hw1, i.e. the files aboutme.txt, Lists.java, and Encoding.java. Make sure these files do not have package declarations.

Add me as a contributor to your repo. My BitBucket and GitHub ids are cayhorstmann.

Did I mention that your files should not have package declarations?

Don't know Git? Check out this lab that our CS46B students take. That lab (and this course) also assumes familiarity with the bash shell; see this lab. If you run Windows, you should install a Linux virtual machine.

Send an email to Cay.Horstmann@sjsu.edu with subject line

CS151 Repo

and the URL to your repo in the body of your message.

Important: If you are currently enrolled in the class, you must turn in a complete or partial solution to this assignment by the deadline, or you may be dropped from the class. If you are trying to add the class, you will receive an add code after you have turned in the assignment.