2. Ministry of Higher Education Course: File organization- INF 221
Higher Technological Institute
Computer Science Department
Second Year
Sheet 5: Sequential and Direct File Organization Theoretical
1. Define each of the following with example:
• Record: Unit of information which contains data about individual entities.
• Field: is a decompose atomic unit of the record.
2. Compare between sequential search and direct access?
Sequential Search: is a method (algorithm) of searching a file by reading the file from the
beginning and continuing until you have read in every thing that you need.
Look at records sequentially until matching record is found. Time is in O(n) for n records.
Appropriate for pattern matching, file with few records.
Direct Access: it is based on disk model. It allows random access. User can jump to any record
and access that record. Following operations are supported.
Being able to seek directly to the beginning of the record. Time is in O(1) for n records.
Possible when we know the Relative Record Number (RRN): First record has RRN 0, the
next has RRN 1, etc.
3. What is the difference between binary and interpolation search?
The binary search method requires:
•records are stored in a sorted list.
•the list is randomly accessible
Interpolation search
This search algorithm works on the probing position of the required value. For this algorithm to
work properly, the data collection should be in a sorted form and equally distributed.
4. Describe in details self organizing sequential search?
Self-organizing lists modify the order in which records are stored based on the actual or
expected access pattern. The goal is to achieve an ordering that keeps the most frequently
sought records closest to the front of the list.
Common heuristics:
•frequency count: order by the actual historical frequency of access
•move-to-front: when a record is accessed, move it to the front of the list
•transpose: when a record is accessed, swap it with the preceding record in the list
Problems
5. Using binary search for the following sequence to search 18:
Programs
6. Write a program for problem 5 by using C or C++.
Research
3. 7. Make problem 6 by any IDE for C/C++.
with all my best wishes
| P a g e 1