CMPSCI 187: Programming With Data Structures
David Mix Barrington
Homework Assignment #1
Posted Saturday 17 September 2011
Due on paper in lecture, Monday 26 September 2011
Correction in purple added 18 September.
Correction in brown added 18 September.
- Question 1 (15): SPIRE is UMass' system for online
course information and registration. Choose three of the eight
aspects of software quality in L&C Chapter 1, and comment on how
SPIRE is a good or bad piece of software with respect to those
- Question 2 (10) Do Exercises 2.1 and 2.2 on pages 24-25
of L&C. (For example, the "order of" the function 2n + 6 is
- Question 3 (20) For each of the two code fragments in Exercises
2.4 and 2.5 on page 25 of L&C, give the order of the growth function
justify your answer. Correction: L&C meant to say
count2=1" instead of "
count2=0". Solve the problem
with this change in the code, and say what will happen to the method if this
change is not made.
- Question 4 (15) The statement "O(n2) +
O(n2) = O(n2)" means "if f and g are each
functions that are bounded above by quadratic functions, then f + g
is also bounded above by a quadratic function". Explain why this is
Then determine the order of "O(n)[O(n) + O(1)] + O(n) +
and justify your answer.
- Question 5 (20) Do Exercises 3.4 and 3.5 on page 66 of
In Exercise 3.5, I earlier said "assume that each of the three parts starts over
with the result of Exercise 3.4" but this makes no sense as (b) and (c) are
the same commands. Assume that the operations of (a), (b), (c) take place
sequentially in that order.
- Question 6 (20) Write a Java static method
Integer[ ] rearrange (Integer [ ] input)
that will take any array of Integer objects as inputs and return
an array of the same length containing the same objects but such that
(a) all the even numbers come before the odd numbers, (b) all the
even numbers are in the same relative order, (c) all the original
odd numbers are in reverse order relative to their position in
Last modified 18 September 2011