CMSI 282 Problem Set #2
Due February 17, 2009
1) Compute each of the following… by hand! For each one, indicate your method and
show all intermediate results:
a) 513
b) 314
c) 12061/2 (the square of your result must be within one thousandth of 1206)
d) 181/3 (the cube of your result must be within one thousandth of 18
e) Among the following numbers, which is the 31st (thirty-first) smallest?
2) Make public static double nthRoot ( int n, double x ), which returns the nth root of x
using your own generalization of Newton’s method for finding square roots, as
discussed in class. Explain your technique, and embed the method within a program
called RootFinder.java, which I will be able to test.
3) Here's a maximum heap, illustrated as an array:
index value
1 82
2 61
3 75
4 18
5 31
6 53
a) Insert 80 and, after it has “settled,” draw the heap (as an array).
b) From there, remove the max value and redraw the heap.
c) From there, remove the max value again and redraw the heap.
d) Insert 43 and, after it has “settled,” redraw the heap.