Hello World - Spring 2007

Homework 1

Attempt by: Monday, January 22
Due by: Thursday, January 25
  1. Read Chapter 1 of the course text.

  2. Do the following problems from Chapter 1 (page 34): exercises 1, 6, 7a, 8, and 9.

  3. Consider the following algorithm:

          1. Get two positive integers as input. Call them R and D, respectively.
          2. Let Q be 0.
          3. If R is less than D, go to step 7.
          4. Increase Q's value by 1.
          5. Subtract D from R.
          6. Go back to step 3.
          7. Print out Q and R.
    
    1. Go through the algorithm, step-by-step, to show the output produced when the inputs are as follows:

        i)   R is 4 and D is 2.
        ii)  R is 15 and D is 5.
        iii) R is 29 and D is 7.
      
    2. In a clear and concise sentence explain what this algorithm can be used to compute.

    3. If we remove the restriction that D must be a positive integer, is this still an algorithm? Explain.