|
|
|
|
|
by aliceryhl
2039 days ago
|
|
I'm also one of those people who think people should know rudimentary data structures and algorithms, and the reason I think this is that they come up all the time! Sure, you could get through the situations I'm thinking of without knowing anything about this, but if you don't think about it, you risk filling the code with lots of O(n^2) loops that could be O(n) if you added an extra map. This is how you end up with applications that are slow due to a thousand small cuts. If you don't think about these things, then I can only assume that it's because you don't notice them when they come up. To be clear, there's nothing wrong with choosing the slower implementation because its simpler. What's important is that you thought about the trade-off, and often the O(n) loop is not more complicated than the O(n^2) one. |
|