levo

Organisation of Data: Files and Records

Sequential file access and update algorithms

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

Overview

Recall questions on the open–read–process–close sequence, the end-of-file marker, pseudocode to read and to total a file, the master-and-transaction update algorithm case by case, why both files must be sorted, and why a longer record cannot be written back in place.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Outline the algorithm for updating a sequential master file from a transaction file.

Process

What is the standard sequence of operations for handling a file in a program?

Process

Write pseudocode that reads and processes every record of a sequential file.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is the standard sequence of operations for handling a file in a program?

    Model answer

    The file is opened in the mode required, records are then read or written, and finally the file is closed.

  2. 2

    Why must a file be closed when a program has finished with it?

    Model answer

    Closing writes out anything still sitting in the buffer and releases the file, so no data is lost and other programs are able to use it.

  3. 3

    What is the end-of-file marker for?

    Model answer

    It signals that there are no records left, which is what allows a reading loop to know when to stop.

  4. 4

    Write pseudocode that reads and processes every record of a sequential file.

    Model answer

    OPEN the file for reading, then WHILE NOT end of file, READ the next record, process it, END WHILE, and CLOSE the file.

  5. 5

    Write pseudocode to total a numeric field over an entire sequential file.

    Model answer

    Set total to 0 and open the file, then WHILE NOT end of file, READ a record and set total to total + the record's amount, END WHILE, close the file and output total.

  6. 6

    Outline the algorithm for updating a sequential master file from a transaction file.

    Model answer

    With both files in the same key order, read the first record from each and compare the keys; where they match apply the change and write the amended record, where the master key is lower write the master record out unchanged, and where the transaction key is lower treat it as an insertion or an error, moving on through both files until each is exhausted.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

Fetch, , execute.
decodecompilestore

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Organisation of Data: Files and Records, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.