CS160
Assignment #1
DUE : Thursday 9/9.
In the textbook:
- 1.5. Note that the statement of the problem suggests computing the number
of 1's for an int parameter, which you should do.
As a warm-up, try writing a method that determines the
length of the binary representation (it's a little simpler).
It is not necessary to implement
these methods, but if you want to, please go ahead.
-
You can use a very similar idea to the one in the previous problem
to write a method that
converts a string (meaning, of course, a
String) of 0's and
1's to its decimal (i.e., int) value. Do it! Ground rules: You may use
only the charAt(), substring() and
length() methods of String.
- 1.11(b); prove by induction.
- 1.12(b); prove by induction. Use this and what you know
about ∑i=1Ni (see page 5) to show that ∑i=1Ni3 = O(N6).
- 2.1
- 2.6
Back to
CS160 Home Page