Omar_Hafez's blog

By Omar_Hafez, history, 3 years ago, In English

Hello, I am new to competitive programming and when I learn a new technique or algorithm I really don't know is it important to understand why this algorithm work or what is the math behind this algorithm ? or just I need to understand how it works and how to use it to solve the problems that this algorithm or technique fit in?

  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it +21 Vote: I do not like it

As a beginner , the major algorithms that you will require are binary search and prefix sums and............yeah that is pretty much it. Rest is all greedy, observations, math and sometimes combinatorics. That is all. As far as binary search and prefix sums are concerned, yes, you should get into their depths, these two are frequently used, doesn't matter if you are a div 1 or div 2 participant. For stuff like dp,yeah perhaps understanding how to write dp states and transitions is helpful,although you won't encounter too many dp problems as a beginner.As you gain experience,you may require more algorithms, but that is something that is better learnt while practising and spending time on harder problems

»
3 years ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

To get out of newbie rank, I think all one needs is decent math background (ie 80+ AMC score) and basic programming ability. I was ~1200 while knowing practically no algorithms but being an AIME qualifier.

I would say algorithms aren't really necessary to get out of newbie.

But when you do learn an algorithm, of course you should know why it works, the math behind it, etc. Codeforces is extensions of algorithms, not just copy-paste [algorithm].

»
3 years ago, # |
  Vote: I like it -31 Vote: I do not like it

In a interview it is better to explain it to the person interviewing you, on codeforces being good is just about having good tempelates.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it -11 Vote: I do not like it

    Why was I downvoted?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Because an unhelpful sarcastic answer to a genuine question is what downvotes are meant for.

      • »
        »
        »
        »
        3 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        aree tere bhai ke pas coding interview me experience hai that is why I say for coding interviews prep you need to learn everything completely but for cf u dont really need to have that deep of a understanding of many advanced topics because they are mostly used as tools. For example, segment trees, you dont need to learn how it works just need to know how/when to use them.

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          codeforces is not a coding interview preparation site, kindly keep your advice to yourself.

»
3 years ago, # |
  Vote: I like it +9 Vote: I do not like it

if the goal is to become a better problem solver then I think it is more important to understand why an algorithm works than being able to fit it in places.

try proving algorithms(if not a rigorous mathematical proof at least a proof that you can convince yourself with), this helps you in becoming a better problem solver + makes you more capable of designing your own algorithms.

so yep according to me understanding why "it" works is super important.