|
|
|
Appropriate usage of data structures
|
|
4 points
by nvbhargava
4089 days ago
|
|
Appropriate data structures, when used correctly, can improve the speed/memory efficiency drastically. But I believe that many people resort to using hash tables at the end of the day just because they are the easiest to use. So, I was curious to see if you use (or maybe built from scratch) any data structures (trees, graphs etc.) regularly at your work or for your side projects? |
|
For me, it's a matter of avoiding premature optimization. When I end up dealing with needing to optimize my code, very rarely is the data structure the primary pain point. Just because something is "easy to use" doesn't necessarily mean that the faster alternative is worth the opportunity costs.
I prefer the Donald Knuth quote:
"Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."