0

Algorithm efficiency. Help

If I use an auxiliar array to solve a problem and the code will be less written, will it be more efficient than just writing much bigger code so the calculations only happen in the same array. I am not using any functions, everything is written in the main function. My question is, on what does efficiency of the program depend in the main function? Thank you for any help :)

16th Aug 2018, 12:22 PM
Filip German
Filip German - avatar
2 ответов
+ 1
First of all there are two types of efficiency: temporal (trying to get your program to be as fast as possible) and spacial (trying to use as little memory as possible). There are many times in Programming when you have to pick one over the other. In trivial programs these choices don't matter and you're better off going with what seems to be most sane. Now, generally, the size of the code does NOT matter. while (1); is just one line of code but has infinite temporal inefficiency.
16th Aug 2018, 12:41 PM
Vlad Serbu
Vlad Serbu - avatar
0
Thx mate :)
16th Aug 2018, 12:46 PM
Filip German
Filip German - avatar