Loading section...
Streaming Two Pointers: When Data Does Not Fit in Memory
Concepts: pyExternalSort, pyStreamingMerge
The staff-level twist on any two-pointer problem: 'What if the data does not fit in memory?' This is where the interview shifts from algorithms to system design. The two-pointer technique works on arrays because you can random-access any position. On a stream, you can only move forward. On data larger than memory, you cannot hold the full input. The candidate who can adapt two pointers to streaming and external scenarios demonstrates the systems thinking that defines L6. External Sort Merge You have 100 GB of data and 4 GB of memory. You cannot sort in memory. External sort: (1) read 4 GB chunks, sort each in memory, write to disk. (2) K-way merge the sorted chunks using a min-heap with one entry per chunk. The merge step is a K-way two-pointer merge where each 'pointer' is a file reader p