Exercise 3.4 on page 79
Exercise 3.7 on pages 79-80
Exercise 3.18 on page 81
Exercise 3.x2: Suppose we define a sequence of sets of ordered pairs as follows. Let the set S0 = {} and for each integer k > 0, let the set Sk = {(0,0)} ∪ {(n, p+2) | (n−1, p) ∈ Sk−1}. What set is the limit of this sequence as k goes to infinity?
Exercise 4.x1:
Table 4.3 on page 94 lists the precedence of operators, but in order to understand an expression that contains two or more operators of equal precedence, you also need to know whether they are left-associative or right-associative, that is, whether they group to the left or the right. What would be the fully parenthesized version of the following C, C++, or Java expression?
a = b = c / d / e
In addition to understanding the grouping of operators, it is
necessary to understand what values they produce. Sometimes this is
subtle. For example, you might think that 0 is the only integer that will yield itself
when divided by -1, but in Java that is not true. Using the Java Language
Specification, determine what nonzero value you can fill
into the blank in the following program so that the message "You
got it right!"
is displayed.
public class Division { public static void main(String[] args){ int dividend = _____________; int quotient = dividend / -1; if(dividend == quotient) System.out.println("You got it right!"); else System.out.println("Try again."); } }
The least appreciated operator in C/C++/Java may well be
?:
. Rewrite the above program to use this operator,
thereby avoiding the if
statement. Which version do you
prefer? Why?