Assigned 25 Oct, due 3 Nov.
Problem 1: You are given a sorted list of positive floating-point
numbers to add up. Should you add them in increasing order, decreasing
order, or doesn't it matter?
Problem 2:
The definition of integer division is, given two numbers "dividend" and
"divisor", to find two other numbers "quotient" and "remainder" so that
dividend = quotient * divisor + remainder
and "remainder" is smaller than "divisor". When everything is positive,
this is easy. But what happens when the dividend and/or the divisor is
negative? For example, 14 divided by -5 could give
q=-2,r=4; this satisfies the equation, since 14 = (-2)*(-5)+4, or
maybe q=-3,r=-1; this works too, since 14 = (-3)*(-5)+(-1).
Similarly, -14 divided by 5 could give
q=-3,r=1, since -14 = (-3)*5 + 1, or
q=-2,r=-4, since -14 = (-2)*5) + (-4).
-14 divided by -5 could give
q=3,r=1, since -14 = 3*(-5)+1, or
q=2,r=-4, since -14 = 2*(-5)+(-4).
Some people say the remainder should have the same sign as the dividend:
14/-5 = -2, remainder 4,
(-14)/5 = -2, remainder -4, and
(-14)/(-5) = 2, remainder -4.
Other people say the remainder should have the same sign as the divisor:
14/-5 = -3, remainder -1,
(-14)/5 = -3, remainder 1, and
(-14)/(-5) = 2, remainder -4.
Which side (or neither) do you agree with? Why? Can you find a good
argument for both sides?
Problems on Chapter 6: 6.10, 6.11, 6.13
Problems on Chapter 7: 7.1, 7.7, 7.11, 7.15