CS FundamentalsModerateGATE CS

A directory with 10,000 entries is stored as an unsorted linear list. File creation must check that the name does not already exist. Which change speeds up both lookup and creation the most?

  1. A. Sort the list after every creation
  2. B. Use contiguous allocation for the directory file
  3. C. Increase the block size
  4. D. Store the entries in a hash table (or B-tree) keyed by file name

Correct answer: D. Store the entries in a hash table (or B-tree) keyed by file name

A hash table makes lookup and duplicate checking expected O(1) (a B-tree gives O(log n) and ordered listing, as in ext4 htree or NTFS). A sorted list still needs shifting on insertion.

More Operating Systems questions

Exams that ask this topic