Assume that data you need to access/update is always specified by “offset addres
ID: 3830846 • Letter: A
Question
Assume that data you need to access/update is always specified by “offset address” in a file, which indicates how many bytes the target data is away from the beginning of the file. Which file organization (contiguous, linked-list or index) would you choose to maximize efficiency in terms of speed of the data access (select the best file organization for each of the five cases below), when:
QUESTION 4 (7.5 minutes) 10 points Assume that data you need to access/update is always specified by "offset address" in a file, which indicates how many bytes the target data is away from the beginning of the file. Which file organization (contiguous, linked-list or index) would you choose to maximize efficiency in terms of speed of the data access (select the best file organization for each of the five cases below), when: (a) Data is rarely updated (almost no update) but frequently read in random order (the locations of the target data are random). (b) Data is added always at the beginning offiles. (c) Data is rarely updated (almost no update) but frequently read in the sequential order from the beginning to the end of files. (d Data at random locations in a file is frequently updated (e) Data is deleted always at the end of files. Note l: No explanation is necessary for your solutions Note 2: The term, "update means modifying the content of data but nondeletion or addition of new data) The term, "access means reading the data. Note 3: Do not assume that there is always some empty disk blocks before the first data block and after the last data block in a file.Explanation / Answer
a)
When data is rarely updated and in random index order, array data structure is good since any time user can switch to desired index and update it.
eg: a[5] = new_val;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
b)
Stack data structure is good option when always want to add at beginninf of files. Since stack follows last in first out structure. It always add on top and also remove top element first.
------------------------------------------------------------------------------------------------------------------------------------------------------------
c)
When data is rarely updated and iterating sequentially, array data structure is good. Since any time user can switch to desired index and update it. Iterating starts from index 0 to array.length-1
------------------------------------------------------------------------------------------------------------------------------------------------------
d)
Data at random location updated means array is good choice any time user can switch to desired index and update it.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
e)
When data is deleting always at end means..queue is good choice since it always pop data from end.