levo

Organisation of Data: Files and Records

Sequential file access and update algorithms

  • 3 things to know
  • AS Unit 1

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

Fetch, , execute.
decodecompilestore

Blank Blitz makes facts automatic

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

AEncryption is reversible.
BThe stored form could be decrypted.
CA hash cannot be reversed.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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