Independent reviewer · not a CSC or DICT publicationSign in to practice

Study notes · File access · DICT

File Access Methods

File access methods decide how a program reaches a record. The 2023 DICT FAQ also lists file handling among the hands-on areas, so practise it in code, not only in theory.

2023 FAQ (copy)Scope: Sequential, direct and indexed access; file operations.

§1 Access methods

For fixed-length records numbered from 1, the byte offset of record n is (n − 1) × record length.

MethodHowBest for
SequentialRead records in order from the startBatch processing every record
Direct (random)Jump to a computed positionFixed-length records, quick lookup
Indexed sequentialSorted records plus an indexBoth batch runs and lookups

§2 File operations

! Common traps

  • Opening an existing data file in write mode and erasing it.