crammy90
Member
- Joined
- Mar 26, 2006
- Messages
- 264
- Gender
- Male
- HSC
- 2008
So a sequential file uses delimiters and a sentinel value to show when its the eof.
a question from 2006 trial 2006.
We are reading a sequential file which has an array of records on it. Records in the array are sorted on surname of students.
Now, i was under the impression that a sequential file would store the array of records as like a stream with the delimiter (i.e. TAB if TAB delimited separating them). i.e.
sof----record1 TAB record2 TAB record 3 TAB----eof
we had to justify why we would use an array of record for the student's details. I understand how to justify this. The answer was:
"we need an array of records as it is necessary to read in every record from the file and allow the searching to be done quickly in RAM rather than by having to read the sequential file multiple times to access the required records as part of the binary search"
now, to me this implies with the "binary search" that the records are indexed.
im confused
a) i thought sequential files couldnt index and so thats what disallow their ability to random access
Could some1 please help
Also quickly
b) can you have a sequential file which has multiple array of records where inside these array of records their are indexes allowing the binary search, however between the 2 array of records their are only delimiters
i.e. sof-----array of records 1 TAB AOR2--------eof
and inside each AOR their are indexes for the records. So basically when wanting to find a student the program could linear search the sequential file for the student array, and then perform a binary search on that array using the indexes of the records (which are sorted in a logical order)
a question from 2006 trial 2006.
We are reading a sequential file which has an array of records on it. Records in the array are sorted on surname of students.
Now, i was under the impression that a sequential file would store the array of records as like a stream with the delimiter (i.e. TAB if TAB delimited separating them). i.e.
sof----record1 TAB record2 TAB record 3 TAB----eof
we had to justify why we would use an array of record for the student's details. I understand how to justify this. The answer was:
"we need an array of records as it is necessary to read in every record from the file and allow the searching to be done quickly in RAM rather than by having to read the sequential file multiple times to access the required records as part of the binary search"
now, to me this implies with the "binary search" that the records are indexed.
im confused
a) i thought sequential files couldnt index and so thats what disallow their ability to random access
Could some1 please help
Also quickly
b) can you have a sequential file which has multiple array of records where inside these array of records their are indexes allowing the binary search, however between the 2 array of records their are only delimiters
i.e. sof-----array of records 1 TAB AOR2--------eof
and inside each AOR their are indexes for the records. So basically when wanting to find a student the program could linear search the sequential file for the student array, and then perform a binary search on that array using the indexes of the records (which are sorted in a logical order)
- but then that means in a Random access file if there were multiple arrays of records in the file, there would be indexes for each of these AOR, and then another index for the records within the AOR?