OA. free
Free
MathWorks Core Computer Science Data Structures & Algorithms Medium

B-Trees are commonly used for which primary purpose in database and file systems?

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

B-Trees are commonly used for which primary purpose in database and file systems?

Choose one option.
Show answer & explanation
Answer: A. Speeding up database search, delete, and insert operations on disk storage

B-Trees are specifically designed to minimize disk I/O operations by maintaining balanced trees with high fanout (many children per node), reducing tree height and the number of disk accesses needed for search, insert, and delete operations. This makes them ideal for secondary storage indexing in databases and file systems. Options B, C, and D describe unrelated purposes—sorting algorithms, consistency checking, and hash table organization are not primary use cases for B-Trees.

Step-by-step Derivation:
B-Trees are optimized for external storage (disk-based) access patterns:

  1. High branching factor: Each node can hold many keys and child pointers, reducing tree depth from O(log n) binary trees to O(log_b n) where b is the branching factor.
  2. Disk access pattern: With fewer levels, fewer disk seeks are required per operation.
  3. Balanced guarantee: All leaves are at the same depth, ensuring consistent O(log n) performance.
  4. Real-world usage: Database indexes (e.g., MySQL InnoDB, PostgreSQL), file systems (NTFS, ext4), and key-value stores (LevelDB) use B-Trees or B+ Tree variants.

Contrast with other options:

  • B: Sorting is better handled by merge sort or quicksort algorithms, not tree structures.
  • C: Consistency checking uses constraints and triggers, not inherent tree properties.
  • D: Hash tables are flat structures; B-Trees don't organize them—they're separate data structures.