-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.

7
  • 2
    Possible duplicate of Choosing the right Design Pattern
    – gnat
    Commented Oct 9, 2017 at 14:31
  • 1
    @gnat - Explained my problem in detail. Commented Oct 9, 2017 at 14:53
  • 4
    Programming or solving programming problems does not work like an automaton where you just feed some preconditions in and get some solution out. That is why you need trained experts for doing it seriously.
    – Doc Brown
    Commented Oct 9, 2017 at 18:41
  • @DocBrown This is something that has always puzzled me: if we have been doing this for so long, you would think that we would have it down by now, every problem that comes up should just be a slam dunk. What has gone wrong? Why in the world is there not just a list of problem :: solution pairs? If you ask an expert for a first cut answer, most of them will agree, so obviously the OP has a point. Once you have eliminated the impossible, whatever remains should just be bone-obvious.
    – user251748
    Commented Oct 9, 2017 at 19:28
  • 3
    @nocomprende: I am sure there has nothing "gone wrong". If problem solving shall ever become just a matter of looking into some "dictionary of already solved problems", lots of people (including myself) will become unemployed. But I am confident this will not happen during my lifetime.
    – Doc Brown
    Commented Oct 9, 2017 at 19:55

2 Answers 2

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.

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.

3
  • What shall we teach about how to deal with new problems? Perhaps approaches that have been found successful in the past? What shall we teach about programming at all? Things people have already done. We cannot teach general-purpose problem solving, it would be like teaching "how to be smart". I think that 99% of the time, programmers are simply doing things that have been done many times before, with slight variations. We should realize this, pool our efforts, and solve some real problems with the excess capacity that becomes available. But, that would be a general solution, I suppose.
    – user251748
    Commented Oct 10, 2017 at 22:08
  • @nocomprende - We can teach methodologies of how to approach a new problem such as, for instance, decompose it in subproblems that have been solved before. But actually, in the end, the whole teaching process aims at selecting smarter people.
    – mouviciel
    Commented Oct 11, 2017 at 8:07
  • If it is basically a selection process, perhaps we should start at an earlier age and concentrate efforts only on those suitable for any particular field?
    – user251748
    Commented Oct 11, 2017 at 11:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.