How can we remember long codes that we write in C++…so that we can use it to solve another problems ?

# How to remember long codes...

Remember the algorithms!!!

And then just convert it to code, when you need it.

Well you dont need to learn codes, you dont even need to learn algorithms at first you must be heading to the basic questions…which are called **adhoc** these type of programming questions dont need any standard algorithm…they are basic/logic types.

Actually i think just jumping to standard algorithms without having any prior programming experience is a destructive approach.

Also You can print out commonly used C++ functions and STL handbook so you dont have to remember those after some practice they will be inscribed in your head.

**You can google more about adhoc questions.**

Thanks sir…but for every problem is it necessary that there is an algorithm…and by algorithm how can we approach…in coding competetions i saw a lot of codes large enough ( approx 200 line )…does the users type these much code themselves or copy paste will also work ?

For most problems, there is (atleast) one algorithm behind it.

By learning an algorithm, we just understand the working of the soln to a problem.

For example, the bubble sort algorithm just swaps two adjacent data items, if they are out of order. This is continued, until there are no more out-of-order elements to swap. Armed with this idea, you can code this one in any language you choose, using the features available. You can also add your own little optimizations.

Once you learn algorithms, you will enjoy writing out hundreds (or probably thousands) of lines of code.

And learning algorithms also makes learning a few (or even more) data structures a necessity, which is in fact good for a programmer.

Thanks sir…what is the best way to learn algorithm…i have corman book …algorithms are theory …so i just read and understand them…any suggestion from you…how you have done algorithms and codings when u r beginner like me ???

Constant practise. That is the only way you learn programming. Getting the theory is easy. But getting it into the code might need some thinking and work, which you get only through constant practise. And www.codechef.com is one of the best platform to learn. (This is where I did learn, when I began.)