Docsity

File organization midterm answers, Exams of Organizational Communication

Toggle sidebar
bg1
Question 1:
a) Illustrate the following terms:
• File Organization
• Transaction File
• Relative File Organization
• File Maintenance
• Sequential File Organization
• Hashing Function
Answer
1. File Organization: It refers to the way records are stored in an external file.
2. File Maintenance: involves updating a master f ile with transactions to keep the data in the
master file up-to-date. Transactions consist of:
• addition of new records
• changing data in existing records
• deletion of existing records
3. Transaction File: contains records of changes, additions, and deletions made to a master file.
4. Sequential File Organization: The physical order of records in a sequential file in the same as the
logical order. The records must be accessed sequentially from the beginning of the file to the
end.
5. Relative File Organization: Is a physical organization upon which the indexing techniques ( direct
addressing, Hashing, B-trees, Index Tables ) are based to directly access a record in the file given
its primary key
6. Hashing Function: Hashing is the application of a function to the key value that results in
mapping the range of possible key value into a smaller range of relative addresses.
pf3
pf4
pf5

Partial preview of the text

Download File organization midterm answers and more Exams Organizational Communication in PDF only on Docsity!

Question 1:

a) Illustrate the following terms:

  • File Organization
  • Transaction File
  • Relative File Organization
    • File Maintenance
    • Sequential File Organization
    • Hashing Function **Answer
  1. File Organization:** It refers to the way records are stored in an external file. 2. File Maintenance: involves updating a master f ile with transactions to keep the data in the master file up-to-date. Transactions consist of:
  • addition of new records
  • changing data in existing records
  • deletion of existing records 3. Transaction File: contains records of changes, additions, and deletions made to a master file. 4. Sequential File Organization: The physical order of records in a sequential file in the same as the logical order. The records must be accessed sequentially from the beginning of the file to the end. 5. Relative File Organization: Is a physical organization upon which the indexing techniques ( direct addressing, Hashing, B-trees, Index Tables ) are based to directly access a record in the file given its primary key 6. Hashing Function: Hashing is the application of a function to the key value that results in mapping the range of possible key value into a smaller range of relative addresses.

b) What is the difference between internal sort and external sort? Explain the phases of the balanced two-way sort merge for sorting large data files that exceed the main memory of a computer. Consider the following record keys: 66 89 61 70 83 108 77 73 76 72 71 67 63 107 52 55 80 34 118

  • Show the file contents after the sort phase and after each merge phase of the two-way sort/merge algorithm. Assume that the initial runs contains two records. Answer 1)
  • Internal Sort: sorting data in main memory.
  • External Sort: sorting data in files stored in hard disk. 2)
  • Sort Phase: The records on the file to be sorted are divided into several groups. Each group is called a run, and each run fits into main memory. An internal sort is applied to each run, and the resulting sorted runs are distributed to two external files.
  • Merge Phase: Instead of merging two input files into one output file, stores the merged runs alternately on two output files. This eliminates the need to redistribute the runs to the two input files before the merge can be repeated.

Merge 2 File 3 61 66 70 73 77 83 89 108 52 55 63 67 71 72 76 107 34 80 118 File 1 61 66 70 73 77 83 89 108 34 80 118 File 2 52 55 63 67 71 72 76 107 Merge 3 File 3 52 55 61 63 66 67 70 71 72 73 76 77 83 89 107 108 30 80 118 File 1 52 55 61 63 66 67 70 71 72 73 76 77 83 89 107 108 File 2 30 80 118 Merge 4 File 3 30 52 55 61 63 66 67 70 71 72 73 76 77 80 83 89 107 108 118 File 1 , 2 empty One run stop complete

Question 2:

a) What is the purpose of blocking? What are the factors affecting the blocking factors? If components are stored in a file with a blocking factor of m , and there are n blocks in the file, how many logical and physical accesses do we need to input the file? Trace the sequence of steps involved in reading a block of logical records to a blocked file. **Answer

  1. The purpose of blocking:** reduces the number of physical addresses (I/O operations) to the file and thereby improves the execution time of programs that access the blocked file. 2) Factors affecting the blocking factors:
  • Size of main memory
  • Size of the largest program accessing the file
  • Accesses to the file
  • Physical characteristics of external storage devices 3) Logical Access Physical Access The act of writing components to buffer n x m = Total no. of records Write the buffer in External FILE m = no. of blocks 4)
  • One track = sector size x sectors per track = (8 x 1024) x 600 = 4,915,200 bytes
  • One cylinder = track size x surfaces per disk pack = 4,915,200 x 21 = 103,219,200 bytes
  • One surface = track size x track per surfaces = 4,915,200 x 600 = 2,949,120,000 bytes
  • One disk = 2 x surface size = 2 x 2,949,120,000 = 5,898,240,000 bytes
  • One disk pack = surface per track x surface size = 21 x 2,949,120,000 = 6.193152x10^10 3)
  • Average seek time = (min. seek time + max. seek time) / 2 = (3 + 23) / 2 = 13 ms
  • Rotational time = (1 x 60 x 1000) / rotational speed = 60000 / 5400 = 11.11 ms
  • Average latency time = 0.5 x rotational time = 0.5 x 11.11 = 5.555 ms
  • Average overhead time = average seek time + average latency time = 18.555 ms File A File B No. of Logical records 8000 8000 Record length in bytes 800 800 Blocking factor 5 80 No. of physical blocks 8000 / 5 = 1600 8000 / 80 = 100 Block length in bytes 800 x 5 = 4000 bytes 800 x 80 = 64000 bytes Transfer time for each Block (ms) 0.00904 ms 0.1446 ms Overhead time 18.555 ms 18.555 ms Access time for each Block (ms) 18.564 18. Total access time 18.564 x 1600 = 29702.4 ms = 0.495 min 18.6996 x 100 = 1869.96 ms = 0.03116 min