i just started coding on codechef…i want to know that if i should bother about the execution time and the memory taken by my program?
Hi,
There are three possible answers here.
Yes or No or even…What sort of question is that?
Let me try and explain it a bit
In the beginning, you will feel intimidated if you are a beginner (I felt super scared when I first started) and you will possibly struggle a lot, even with the most simple problems.
At this stage, worrying about memory and execution time is not only pointless as it might even be harmful to you, as you will focus on code efficiency when you possibly should be focusing on the algorithm/data structure itself.
When you feel more comfortable with the cakewalk and maybe simple problems, you will begin to realize than on the next stage: simple/easy, sometimes, the brute force approach you used is not so good, and that the vectors you are filling are giving you TLE veredict.
At this point, you will realize that, in order to solve more complicated problems, sometimes you need equally complicated methods and/or data structures.
It’s not that these structures are complicated, per si. Simply, they are complicated to you NOW.
For example, when I first learnt about the usefulness of associative arrays (std::map 's in C++) I was in awe!!!
I struggled a lot to understand it at the beginning, read many tutorials, editorials, read Cppreference website… but was always struggling with implementation… Until the problem TOURMAP came up in the NOV12 challenge (that’s way over 1 year ago… Now I’m a completely different programmer… not necessarily better, but, definitely more informed and with a lot more knowledge, even if some of that knowledge is only on a theoretical level yet…).
Learning about maps, literally opened my eyes, and made me realize one super important thing back then:
Time and memory go hand in hand with efficient data structures knowledge
So, from a pratical point of view:
Maths Knowledge + Data Structures Knowledge = Good algorithms knowledge
at least, this is what I’ve been feeling ever since and I’ve focused my efforts on reading and learning about data structures, methods to explore/sort/traverse those data structures and also reading about Maths for Computer Science
If you do this or any other “empirical”/“indirect” method that you find useful for you, you will surely start to realize how time and memory entwine with algorithms!
Good luck,
Bruno