-3

While studying for Data structures and Algorithms, I noticed that there is a pattern/group in which every question falls into. Example - Given this, do/find that - Category 1. use these methods/techniques first and then approach it. Similarly for another set of questions.

Do we have a list of patterns which we can understand, so that next time we see a problem, we can identify which category it may fall into and follow those steps to approach it first rather than mixing up random ways of solving them?

This question is not about using which design-pattern like Singleton or Factory etc, but about categories of questions. Example - Whenever there is a string pattern matching question, try with TRIES first, then move to some other DS. If there is List traversal, use this specific technique first (whichever is most recommended based on time/space complexity), then try something else.

2 Answers2

7

Like design patterns in Software Engineering, I would avoid approaching problems with the intent of using a data structure.

The biggest pitfall with design patterns is that engineers will try throwing design patterns at a problem, and hope that it works. In reality, design patterns should be emergent as you get closer to solving the problem, and then you can better evaluate your solution.

I recently finished interviewing students at a college for a Software Engineering position, and the biggest trip-up was when someone tried to apply an inappropriate data-structure or algorithm to a problem right off-the-bat.

I'm not aware of any lists for data-structures for certain problems, and while I agree it would be useful, I would be wary of using any for starting a problem, only for understand the pro-and-cons of a given approach.

JRJurman
  • 347
3

No. Such a list of patterns doesn't exist.

Because the problem I'm currently solving has never been solved before: different environment, different domain context, different assumptions, different constraints, different expectations from users...

It is more efficient to teach people how to deal with new problems than to build an hypothetic list of patterns that anyone could apply.

mouviciel
  • 15,491