What takes a code less time to completely execute? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What takes a code less time to completely execute?

I often wonder how to make my algorithms take less time while execution.

2nd Jul 2018, 6:42 PM
Infinity
Infinity - avatar
5 Answers
3rd Jul 2018, 9:36 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 2
Saurabh Tiwari Thanks 😀
3rd Jul 2018, 9:54 AM
Infinity
Infinity - avatar
0
- Decrease number of steps required to finish - Remove/replace time consuming tasks like calculating cos
2nd Jul 2018, 8:01 PM
TurtleShell
TurtleShell - avatar
0
Additionally to the suggestions from TurtleShell, using compilation time comes to my mind. For example in C++, the compiler is able to evaluate "const" and "constexpr" expressions at compile time, meaning it isn't necessary at runtime anymore, effectively decreasing the runtime of your program. For C++, look up "Template Meta Programming" for more information on this topic.
2nd Jul 2018, 10:56 PM
Shadow
Shadow - avatar
0
void writing lot of if else statement
3rd Jul 2018, 1:12 PM
Driss Aharik
Driss Aharik - avatar