Hello, I have a question for all the REDS/yellows on codeforces, How do you learn algorithm fast?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Hello, I have a question for all the REDS/yellows on codeforces, How do you learn algorithm fast?
Название |
---|
I'm neither red nor yellow, but my advice would be to make sure you fully understand the algorithms you're implementing. You should be able to explain how (and ideally why, although this gets more difficult with advanced algorithms) the algorithm works. From there, it comes down to translating thoughts into code, and that gets easier with practice.
IMO, you should never have to memorize the exact code for an algorithm. At most, you should remember a few implementation tricks specific to the algorithm.
Thank you for the advice Hope you have a great day
Why cope? If I don't understand, it's fun to understand it a bit more each time. If I understand it, it's just a few minutes of coding, so not a big deal.
In general, if you need to code something a 100 times before you're confident, you should probably go back to studying it and understanding it better. Or just learn something else and give it some time — sometimes it takes time for it to settle in your head and to mature as a coder to understand something fully (I wouldn't say I fully understood DFS for the first 4-5 years of my career, even though I could probably code it blindfolded).
What do you mean by you didn't fully understand DFS? And what parts of BFS does OP not understand before they coded 100 times?
Well, I pretended I knew DFS, but I would just memorize algorithms like AP/Bridge finding or SCC, which are just based on DFS properties. One day it just clicked, and I could code them like I was coding any other DFS problem.
The in-out orderings, the all-edges-are-backedges property are very simple when you read about them, but using them creatively in solutions took me that long.
Vidim da ste iz Srbije, pa cu da vam pisem na srpskom :) Ja neznam zasto ali sam mislio da zada bi naucio algoritam trebam da ga kucam dok ga ne memorizujem, ali hvala na savetu. Potrudi cu se da ga primenujem u buducnosti. Imajte lep dan
I think you should put in more time to actually understand it rather than write it 100 times. What I usually did was to carefully study the code for the new algorithm I was trying to learn, then solve a few related easy/standard problems, while trying to write the code on my own, without looking at an example implementation of that new algo. This way, you kind of test if you really understood what you learnt.
Thanks for the helpful advice
you don't. doing something 100 times is stupid.
When I said 100 times I didn't mean like writhing DP 100 times for the Coin Change problem for example, but like you have to learn knapsack, Range DP, Com. DP, Digit DP... And at some point you learn all the things, and you now need to just solve solve Solve. I used BFS as an example, but My question was when you are bad at for example DP you should do more DP problems, but nobody likes to do what they are bad at. So how do you disciplin your self?
Well, if you don't want to do smth, and you can't force yourself to do it, then there is no solution for it.
I really like Greedy, so like every time I code I tend to solve Greedy/math problems instead of DP problems
if you understand something, you don't have to write it even a single time to know how to use it :3 though practice still helps
I am cleary not qualified for this but I think that for learning any algorithm you don't need to write it a 100 times to learn it, don't try to memorize the algorithm, understand it and I think it will mostly take you 20-30 problems to get it.
I don't think i am enough qualified to say something . But when i learn some algorithm for example BFS DFS i try to understand the algorithm step by step . After understanding i try to implement it by myself without seeing the code on the basis of the steps if i fail then i see the code and try to understand how the code if working and logic behind it. After that I try to write that code for 2/3 time. After that I try to solve few easy questions of that algorithm . I learned BFS DFS like this 5/6 month ago and still didn't forget that.
Auto comment: topic has been updated by AndrijaMlad (previous revision, new revision, compare).