Problem

The problem of managing the blocks of an external data file indexed by eidier a B-trce or...

The problem of managing the blocks of an external data file indexed by eidier a B-trce or an external hashing scheme is similar to that of managing memory for internal

example, to insert a new record), it gets a new block from a free list that the system manages. That is, if the file contains N blocks, the system can allocate to it an (N + l)th block. When the file no longer needs a block, you can deallocate it and return it to the system.

The complication in the management of external storage is that a block allocated to a file may have available space interspersed with data. For example, after you have deleted a record from the middle of a data file, the block that contained that record will have space available for at least one record. Therefore, you must be able to keep track of blocks that have space available for one or more records as well as recognize when blocks are completely empty (so that you can return them to the system).

Assuming the existence of allocateBlock and returnBlock methods that get empty blocks from and return empty blocks to the system, write pseudocode implementations of the following external memory-management methods:

getSlot(in dataFile:File):BlocklnfoType

// Determines the block number (blockNum) and record

// number (recNum) of an available slot in file

// dataFile. Places this info in a BlocklnfoType object

// for return. A new block is allocated to the file from

// the system if necessary.

freeSlot(in dataFile:File, in blocklnfo:BlocklnfoType)

// Gets recNum and blockNum from blocklnfo.

// Makes record recNum in block blockNum of file

// dataFile available. The block is returned to the

// system if it becomes empty.

What data structure is appropriate to support these operations? You may assume that you can distinguish slots of a block that do not contain a record from those that do. You can make diis distinction either by having a convention for null values within a record or by adding an empty/full flag.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 15
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT