0

I need to write a method thatshould search for the first contiguous set of free blocks that is at least numBlocks in size. It should return the index of the first block in the sequence. If no such sequence exists, return -1.

For example, if the file originally contained the bytes (shown in hex) “3f fc 40 1f” and numBlocks is 4, the method should return 18 (the bit representation of this file is 00111111111111000100000000011111, so the first sequence of 0s of length at least 4 starts at bit 18).

The function start like this:

    public long findSpace(RandomAccessFile file, int num) throws IOException {

    long size = file.length();
    long numBits = size*8;



}
oy1
  • 87
  • 3
  • 11

0 Answers0