Show understanding of methods of file access
📚 13.2 File Organisation and Access
What is File Organisation?
Think of a file as a big library. File organisation decides how books (records) are arranged on the shelves.
- Contiguous – all books in one long shelf.
- Linked – each book points to the next one.
- Indexed – a small index book tells you where each book is.
- Hashed – a key (like a locker number) instantly tells you the shelf.
File Access Methods
How you read or write to a file depends on its organisation.
- Sequential Access – read one book after another, like flipping through a magazine. Best for reading the whole file.
- Random Access – jump straight to a specific book using its address. Like using a library card catalogue.
- Indexed Access – use an index to find the book quickly. Think of a phone book lookup.
- Hashed Access – use a hash function (like a locker number) to locate the book instantly.
Time Complexity Cheat‑Sheet
| Organisation | Access Method | Time |
|---|---|---|
| Contiguous | Sequential | $O(n)$ |
| Linked | Sequential | $O(n)$ |
| Indexed | Random / Indexed | $O(\log n)$ |
| Hashed | Hashed | $O(1)$ |
Exam Tip: Choosing the Right Access Method
When answering questions:
- Identify the file organisation first.
- Match it to the most efficient access method.
- Use the time‑complexity table to justify your choice.
- Remember: Sequential is great for reading all records, Random for updating a single record, Indexed for searching by key, and Hashed for constant‑time lookup.
🧩 Practice: Sketch a small file (5 records) and label which access method would be fastest for each operation.
Quick Quiz
Which file organisation would you use if you need to update a single record many times?
- Contiguous
- Linked
- Indexed
- Hashed
Answer: Hashed – because it gives you $O(1)$ access to the record you want to change.
Revision
Log in to practice.
2 views
0 suggestions