3 ms·
I think "use a better data structure" needs to be #1. If you have a bad data structure for your use cases, no algorithm change will save you. If you have a lin
by ttfkam 3y ago
I think "use a better data structure" needs to be #1. If you have a bad data structure for your use cases, no algorithm change will save you.
If you have a linked list and your use case tends toward non-sequential search and access, tweaking the algorithm only burns cycles that could be spent switching up. If you have an ordered array and need to insert/delete values in the middle, you are similarly hobbled in performance. Then there's cache coherence when interacting with hardware, which is heavily influenced by data structure.
Data structures should come first when developing and optimizing.