Lesson 0: Why Does Your Choice of Data Structure Matter?
Imagine a phone book with a million names, listed in completely random order. To find one person's number, you'd have to flip through page after page until you hit the right name — about half the pages on average, and every page in the worst case. That exact same phone book, alphabetized, lets you j
Choosing a data structure is like searching a jumbled phone book versus an alphabetized one — the exact same information, but wildly different speed.
- data structure
- An organized way to store information so it can be accessed, searched, and updated.
- lookup
- The operation of finding a specific item inside a collection of data.
- linear scan
- Checking items one after another in order until finding the target — the more items there are, the longer the expected time.
- direct access
- Jumping almost straight to the right spot, without passing through every other item along the way.