Suppose you have a large dataset that does not fit into memory. How would you process that data?
💡 Model Answer
When a dataset is too large to fit into RAM, the key strategy is to process it in smaller, manageable chunks or streams. One common approach is to use a streaming or iterator pattern: read a fixed-size block from disk, process it, and discard it before loading the next block. This keeps memory usage bounded. If the task requires sorting or grouping, external merge sort is effective: split the data into sorted runs that fit in memory, write each run to disk, then merge runs in a priority‑queue‑based k‑way merge. For aggregations like sum or average, a single pass streaming algorithm suffices. If the workload is embarrassingly parallel, frameworks like MapReduce or Spark can distribute chunks across nodes, each node performing local computation and then reducing results. Complexity depends on the algorithm: a single pass streaming aggregation is O(n) time and O(1) extra memory; external sort is O(n log n) time with O(n) disk I/O. The choice of technique hinges on the operation (aggregation, sort, join) and available infrastructure.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500