In: Computer Science
Consider a file with a large number of Person(id, name, birth-date) records. Assume that users frequently search this file based on a the field id to find the values of name or birthdate for people whose information is stored in the file. Moreover, assume that users rarely update current records or insert new records to the file. Which file structure, heap versus sorted, provides the fastest total running time for users’ queries over this file? Explain your answer.
Sorted file structure gives the fastest runtime for the users for any operation on files such as addition of new records, deletion of records etc.
In this Soreted file system data will be stored in ordered form where as in heap file structure data is not stored in ordered form. In heap structure data will be stored in memory blocks which are free without any order.
Using sorted file structure when doing different operations on files it gives the efficient and fastest result, because of the ordered nature compiler will easily Scan and finds out the required position whereas in the heap structure it is very time consuming process to search a file in unordered memory blocks to update, delete or to add files .
So that the sorted file structure is the best suggested one. Here users frequently access files or add's new files etc., It consumes time when access or updates files using heap structure ,so the efficient and the fastest resolution of user queries is accomplished with the Sorted file structure.