Choosing a Data Structure
Choosing a data structure: listing a program's operations and their frequency, picking the structure that makes them cheap, and the built-ins Python, Java and TypeScript provide.
Choosing a data structure means deciding, from what a program does with its data and how often, which structure makes its frequent operations cheap. It matters because a structure picked from habit can turn a common question into a scan of every item, while the right one answers it in constant or logarithmic time. The topic starts with the method and nine questions that sort a program into a structure, then applies them to two programs that look nothing alike: a live leaderboard and a sign-up form that checks usernames as they are typed. It compares the built-in structures of Python, Java and TypeScript and where each has gaps, shows what goes wrong when free appointment slots are kept in a set out of habit, and ends with an exercise on a support queue where urgent tickets jump ahead.
Contents
7 cardsnot started