File organization methods: Which option best describes a direct-access (random) file organization approach?
-
AStoring records in contiguous blocks according to a key
-
BStoring records sequentially but using an index to locate records
-
CUsing a separate index for each key type
-
DPlacing records non-sequentially so that any record can be accessed directly
-
ENone of the above
Answer
Correct Answer: Placing records non-sequentially so that any record can be accessed directly
Explanation
Introduction / Context:Choosing a file organization affects retrieval speed, update cost, and storage overhead. Common strategies include sequential, indexed-sequential, and direct (random) access. Understanding their differences guides design decisions for batch processing versus real-time lookup workloads.
Given Data / Assumptions:
- Direct access aims at fast retrieval of any record without scanning from the beginning.
- Data placement can be computed (e.g., hashing) or mapped via addresses.
- Indexing and sequential storage are related but distinct approaches.
Concept / Approach:In direct-access (random) organization, records are stored so that their location can be determined directly (e.g., via a hashing function on a key) rather than by scanning a sequence. This permits near-constant-time retrievals under good distribution. By contrast, sequential stores in key order and favors batch reads, and indexed-sequential keeps a sequence with an index to speed lookups while preserving order for range scans.
Step-by-Step Solution:
Identify the goal: access any record directly from its key, not by scanning. Exclude options describing purely sequential or indexed-sequential methods. Select the option that emphasizes non-sequential placement allowing direct access. Answer: Direct (random) organization.Verification / Alternative check:Hash files and certain key-to-address schemes exemplify direct access; they compute a storage address from the key and read the record immediately.
Why Other Options Are Wrong:
- Contiguous blocks by key: Sequential, not random.
- Sequential with index: Indexed-sequential, not direct.
- Separate index for each key type: Describes indexing strategy, not direct placement logic.
Common Pitfalls:Assuming any index implies direct access; confusing hash-based direct organization with B-tree indexed-sequential files.
Final Answer:Placing records non-sequentially so that any record can be accessed directly