CS2852
Homework

This is an old version of this course, from Spring 2014. A newer version is avaliable here.

The official HW assignments are made in class, not on this page.

Key

SC
A Self-check exercise taken from the text (Koffman & Wolfgang, 2E). SCA.B.C indicates "Exercises for Section A.B", problem C.
RQ
A Review exercise taken from the text. RQA.B indicates a problem in the blue "Chapter A Review" section, under the "Review Questions" heading.
M
MSOE (instructor) provided problem. MA refers to problem A in the instructor-provided list.
(opt)
An optional homework problem.

Week 1 -- Due in class, Week 2, Monday

  • RQ1.6
  • (opt) RQ1.7
  • M1,3
  • (opt) M2

Instructor problems

  1. a. What exception could be thrown for this code?Dog d = new Animal(); b. Re-write the code to do nothing instead of throwing an exception.
  2. Implement the ArrayList.remove(int index) method.
  3. Implement the ArrayList.remove(Object target) method.
  4. Implement the ArrayList.lastIndexOf(Object target) method.
  5. How is it possible for a method to declare a-non void return type (e.g. double) and not include a return statement? Why might you want to do this?

Week 2

(HW announced in class)

Instructor problems

  1. Complete each sentence by inserting either "array" or "ArrayList." Write or type the full sentence.
    • A/an _______ uses syntax that other objects don't
    • A/an _______ can be resized
    • A/an _______ uses a property instead of a method for length
    • A/an _______ can hold primitive types
    • (optional) Add your own!
  2. Give the Big-O time complexity for T(n) = 8 + 17n + 3n2.
  3. Implement the LinkedList.add(int, E) method.
  4. Implement the ArrayList::ArrayListIterator.remove() method.

Acknowledgement

Many problems provided by Dr. Taylor