Java Reference
In-Depth Information
(c) For nonzero rational numbers a and b, a b if and only if ab > 0.
(d) For nonzero rational numbers a and b, a b if and only if a=b is an
integer.
(e) For rational numbers a and b, a b if and only if ab is an integer.
(f) For rational numbers a and b, a b if and only if jabj 2.
2.3 State whether each of the following relations is a partial ordering, and explain
why or why not.
(a) “isFatherOf” on the set of people.
(b) “isAncestorOf” on the set of people.
(c) “isOlderThan” on the set of people.
(d) “isSisterOf” on the set of people.
(e) fha;bi;ha;ai;hb;aig on the set fa;bg.
(f) fh2; 1i;h1; 3i;h2; 3ig on the set f1; 2; 3g.
2.4 How many total orderings can be defined on a set with n elements? Explain
your answer.
2.5 Define an ADT for a set of integers (remember that a set has no concept of
duplicate elements, and has no concept of order). Your ADT should consist
of the functions that can be performed on a set to control its membership,
check the size, check if a given element is in the set, and so on. Each function
should be defined in terms of its input and output.
2.6 Define an ADT for a bag of integers (remember that a bag may contain du-
plicates, and has no concept of order). Your ADT should consist of the func-
tions that can be performed on a bag to control its membership, check the
size, check if a given element is in the set, and so on. Each function should
be defined in terms of its input and output.
2.7 Define an ADT for a sequence of integers (remember that a sequence may
contain duplicates, and supports the concept of position for its elements).
Your ADT should consist of the functions that can be performed on a se-
quence to control its membership, check the size, check if a given element is
in the set, and so on. Each function should be defined in terms of its input
and output.
2.8 An investor places $30,000 into a stock fund. 10 years later the account has
a value of $69,000. Using logarithms and anti-logarithms, present a formula
for calculating the average annual rate of increase. Then use your formula to
determine the average annual growth rate for this fund.
2.9 Rewrite the factorial function of Section 2.5 without using recursion.
2.10 Rewrite the for loop for the random permutation generator of Section 2.2
as a recursive function.
2.11 Here is a simple recursive function to compute the Fibonacci sequence:
Search WWH ::




Custom Search