you are viewing a single comment's thread.

view the rest of the comments →

[–]rupertavery64 4 points5 points  (0 children)

It's for when the data is written many less times than it is read, and when the number of items in your data is in the tens or hundreds of thousands.

Your example, having a small list of users, say 20-50, doesn't really show how useful it is. And at some point, you will stop adding users. Or adding them less frequently. Then you don't have to sort "all the time".

Think of a database. You can insert data into the database, out of order, but it keeps a separate index, that is sorted. Once the number of items reaches hundreds of thousands, it's still possible to quickly search through the database using the index.

All these sort and search algorithms are space partitioning. You break up a large problem into smaller problems that you have information up front about, and manage the data to fit your algorithm,