pm215 Wrote:Me, I disagree. A lot of a CS degree course isn't really necessary day to day, but the core data structures (list, tree, hash, etc) are so fundamental that you ought to be able to pick a sensible one pretty much immediately. Premature optimisation *is* a bad idea, but "right data structure for the job" is as much about clean and comprehensible code as it is about performance.
Certainly, that's sort of what I meant. Say, you have ten objects you need to keep track of for a loop. You COULD just randomly pick a hash structure and it would "work", but there wouldn't be any logic to it, so I would say that in this case, you didn't really pick a working solution, you just rolled a dice and picked a structure at random. I was mostly talking about knowing you need a hash and debating which kind of hash structure you need. Or even picking between a stack and a list if both options are viable. I mean, a stack can definitely be a lot more effective than a linked list, but there's a reason why both are implemented by the same class in many high level languages, such as python.
If you understand the common structures to some basic degree, I really do think you will pick a "working solution" automatically just in that short period where you plan ahead how you will go about solving a certain problem. Then it will be optimization if you want to dwell on it longer and want to perfect your code.