Please read the new rule regarding the restriction on the use of AI tools. ×

SayedAulia's blog

By SayedAulia, history, 17 months ago, In English

I had a brief conversation with stevenwjy and fonmagnus some days ago regarding whether algorithms used in Competitive Programming are commonly used, or at all used in industries. Their respond were, if I remember correctly and I wish I am not misquoting them, “Mostly not used at all and for some algorithms might be best suit in certain industries meaning you might need to use segment tree in trading (?) but not software engineering.” And I understand their respond, in industry, the challenges are different from competitive programming thus requiring different techniques and approaches to solve them.

Looking at machine learning for example, I see that most of the algorithms and data structure used in CP are absent, and the algorithm/technique that are used in ML like Gradient Descent and Linear Regression is not used in CP at all. Even if Dynamic Programming is used, it is slightly different than what we use in CP. I initially felt devastated at first but at the end I understood that they are totally two different fields requiring different experties.

However I am not sure with the other fields in computer science. Which field do you think has the most similarity with CP? Can you mention where each cp techniques are used in other fields?

I am not by any mean trying to say that competitive programming is useless like some people out there. Certainly it has it own merits specifically in building intuition and improving problem solving skill which certainly help in solving real world problems.

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

| Write comment?
»
17 months ago, # |
Rev. 3   Vote: I like it +16 Vote: I do not like it
in industry, the challenges are different from competitive programming thus requiring different techniques and approaches to solve them.

Looks like you already answered your own question.

There isn't a specific field that will be similar to competitive programming. Competitive programming is a sport! If you're looking for fields that develop algorithms/data structures then there are a lot of research positions that work on these.

  • »
    »
    17 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Well I supposed these techniques (Segment Tree, Convex Hull, Greedy, Shortest Path, etc) are invented by researcher for some purposed, could you tell me their uses in say, Software Engineering or other field of cs?

    • »
      »
      »
      17 months ago, # ^ |
      Rev. 3   Vote: I like it +18 Vote: I do not like it

      In general, I don't think you will see many CP-like structures in software engineering.

      Of course, this depends on what kind of software engineering you're going to be doing (e.g. graphics rendering engines use a LOT of geometry), but mostly you're going to use the other skills that doing CP helps you develop instead of, say, the algorithms or data structures themselves.

      For example, it was quite normal for me (and I guess everyone on this site) to write efficient code the first time around without even thinking about it. I quickly realized that this was not the case for a lot of the juniors (and even some of the mid-level SEs) in my company.

      It was quite common to see code to, for example, merge $$$N$$$ hash maps that ran in the order of $$$O((\sum{|A_i|})^2)$$$ instead of the expected $$$O(\sum{|A_i|})$$$. This is a huge problem as unit tests are usually small and small inputs don't expose this kind of problem. If this gets caught during code review, great! Otherwise, you're looking at future performance problems that are going to be reaaallly hard to track down. Doing it correctly the first time is really nice in this regard.

      There's also other skills that are really nice to have like being able to speedrun through documentation (i.e. problem statement reading & new topic studying skills from CP) or think about weird edge cases (debugging & proving in CP). These are things that CP forces your brain to get used to. You'll probably also be able to do them eventually anyway after years of hands-on SE experience, but CP helps you get a huge headstart IMO.

»
17 months ago, # |
  Vote: I like it -51 Vote: I do not like it

tourist sucks!

  • »
    »
    17 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    aha Mr.zxc, do you think you are good enough to say this? you even can't cb xjn, because she's got a new one, hahaha!

»
17 months ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

I actually did an extensive research work about this topic (if algorithms were used in "real life") and I concluded that some of them actually have an application in many industries.

In addition, these algorithms are not only used in programming, in fact the concepts of these algorithms are also used in our daily life unconsciously.

  • »
    »
    17 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Can you elaborate?

    • »
      »
      »
      17 months ago, # ^ |
        Vote: I like it +18 Vote: I do not like it

      Sure, I will give you a simple example (I would share my work but it's written in Spanish and it's long so it would be kinda of useless).

      Imagine you don't have any algorithmic knowledge and you are trying to find a specific word in a dictionary, what would you do?

      Obviously you wouldn't go from the start to the end of the dictionary checking if you find the right word because it would take you a lot of time.

      Intuitevely you would look for the middle part of the dictionary and check if the words in that page are lexicographically greater or smaller than the word that you are looking for, from that point you can discard one half of the dictionary and keep going until you find your desired word.

      We did this process every time we checked for a word in a dictionary even though we didn't know what even binary search is.

      This was a simple example but from this point you can think for yourself many other examples.

      (Note that my english is not native but hopefully you understood my point).

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

As a game (and software) dev, some commonly used CP techniques (collected from Problemset filters) in games:

  • binary search
  • bitmasks
  • depth/breadth first search
  • dp (caching)
  • geometry
  • shortest paths

In development, you will be implementing your ideas for the most part. You do not need to know any CP techniques, not even binary search*. So the most valuable skill you can get from CP is implementation imo.

Yes, people write $$$O(n^2)$$$ solutions for things that can be done in $$$O(log(n))$$$. But it doesn't matter for games. You usually work with little data simultaneously and you have a lot of space and time for these solutions*. Modern hardware is very powerful.

I am planning to write some tutorials like this for CPers. Maybe one day, when I have time.

* in most cases (99.99%)

»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In my opinion, recursion and binary search are commonly used in other programming fields.

But stuff like Segment Trees seems to be useless, because you won't have $$$10^5$$$ queries in the real world.

Also, nobody will ask you to compute something modulo $$$10^9+7$$$.