WJEC A-Level Computer Science 601-5345-3
Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types
Data Structures
Organisation of Data: Files and Records
Database Systems
The Operating System
Algorithms and Programs
Principles of Programming
Systems Analysis
Software Engineering and Program Construction
Types of Software System
Practical Programming
Data Security and Integrity
Computing, Society and the Law
Advanced Data Structures and Logic
Recursion, Sorting and Searching
Programming Paradigms and Translators
System Design and Human-Computer Interaction
Software Engineering Tools and Professional Practice
Advanced Architecture and Assembly Language
Communication Networks and File Organisation
Number Representation and Floating Point
Databases and Distributed Systems
Operating System Management
Software Systems and Applications
Data Security, Cryptography and Attack
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.
What is the standard sequence of operations for handling a file in a program?
Write pseudocode that reads and processes every record of a sequential file.
Questions from this subtopic
Each one with the model answer underneath.
- 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
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
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
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
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
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.
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.