CS 341 Data Structures Homework 1 (Due via E-mail by 10:00PM, 1/26/2011)

(60 points)

  1. (12 pts) Exercise 17 Chapter 2.
  2. (6 pts) Exercise 1 Chapter 4.  
  3. (6 pts) Exercise 3 Chapter 4.
  4. (6 pts) Exercise 18 Chapter 4.
  5. (30 pts) Consider a Java interface called Rational that specifies the operations on rational numbers.  Mathematically a rational number is defined as the ratio of two integers, where the denominator cannot be zero.  Common methods or operations for such an interface include: Your tasks are:
    1. Provide a formal specification of the Rational interface with the above five methods.  Define this specification as a Java interface, compile that interface, and submit the java file.
    2. Use Java exceptions to deal with any error situations.
    3. Include as part of this specification the behavior for any constructors of a class that implements this interface.
    Note that this is a specification not an implementation question.