Extend the heap abstraction with three operations: allocArray, getAt, and setAt, which allows for treating a chunk

Question:

Extend the heap abstraction with three operations: allocArray, getAt, and setAt, which allows for treating a chunk of memory as a two-dimensional array. Given the row and column sizes, allocArray allocates a chunk of memory sufficient to hold the array. If contiguous space is not available, the allocArray operation throws an exception of type InsufficientMemoryException.

Given the location of the memory chunk, row number, column number, row size, and column size, the getAt operation returns the value stored at that location in the chunk. If the accessed element is outside the legal bounds of the array, the operation throws an exception of type IndexOutOfBoundsException.
Given the location of the memory chunk, row number, column number, row size, column size, and a new value, the setAt operation changes the stored value at that location in the chunk so it is the new value. If the accessed element is outside the legal bounds of the array, the operation throws an exception of type IndexOutOfBoundsException.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: