Блог пользователя aakarshmadhavan

Автор aakarshmadhavan, история, 8 лет назад, По-английски

Hello!

I am struggling horribly hard with greedy algorithms to the point where I am not able to solve 90% of medium+ greedy problems.

I have watched many videos/lectures but its something very difficult for me.

do you have some resources you can share? How do you come up with greedy strategy and also how in the world do you convince yourself that this strategy will indeed work?

Thank you all

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

It is perfect if you have formal proof for your greedy strategy. But you don't always have the tools/time to a formal proof. An alternative way is to generate small cases and work out the answers by hand and observe a pattern before deciding to use greedy. Just pray that it will work. If it doesn't, then you might want to try another strategy.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I know this might not be too helpful, but what works for me is that when I face most greedy problems I have seen similar ones before. I don't like guessing, but when you have seen lots of proofs and when certain things work and when they don't it's pretty easy to sketch the proof during the contest. If you, as me, doesn't want to go in the "pray it works" direction, I would recommend just doing lots of problems, seeing lots of editorials, and proving out of contest when possible why what you did worked or didn't. Soon almost every problem will be a variation of one you know works, and then you can just code it ;)

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Thanks for such a response! I was wondering how many problems should one target for greedy, before most of the variations are covered? I had a look at the number of problems you have solved out of curiosity, but I am not sure if that would be only number of problems you would have solved :p