Do Exercise 14.1 on pages 265-266. By using the cleaned-up HeapManager
from our course web site, you can confine your changes to the findBlockPredecessor
method. You should ensure that findBlockPredecessor
still works in a single pass through the free block list and that any comments are consistent with the code.
You will need to supplement the code sequences in the two hints with appropriate types for the variables. The first line in each code sequence can be of the form
HeapManager mm = new HeapManager(new int[...]);
Similarly, the variables a
, b
, and c
need to be declared to be of type int
in the second code sequence the same way as in the first.
A parenthetical note in the exercise says that you should use the version of HeapManager
that include the coalescing deallocate
. If you would rather use the non-coalescing version, then interchange the last two lines of each of the code sequences. The hints are valid for both the coalescing and the non-coalescing version if you put these two lines in this order:
mm.deallocate(c); mm.deallocate(a);
Do exercise 16.3 on page 315-316. Assume that the interfaces are defined as follows:
interface I1 {}; interface I2 {};
Exercise 17.x1: For each of the following two Java statements, indicate whether it is legal, and if so, explain under what circumstances each exception handler would execute. The first version is
try { System.in.read(); } catch(java.io.CharConversionException e2){ System.err.println("Caught a CharConversionException."); } catch(java.io.IOException e1){ System.err.println("Caught an IOException."); }
and the second version is
try { System.in.read(); } catch(java.io.IOException e1){ System.err.println("Caught an IOException."); } catch(java.io.CharConversionException e2){ System.err.println("Caught a CharConversionException."); }