Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
It depends how much do you want to ptimize it. For example: if you know that your algorith runs with O(n log n) time complexity and you just want to make the hidden constant smaller, you usually try to decrease number of operations used in the algorothm or search for an option that will limit number of uses of a function/few lines of code, etc. I a case when you have an algorothm running with O(n^2) and you want to decrease the complexity to let's say O(n log n) you search for some other path and usually this is harder to do. For recursive algorothms there is a common idea of tail recursion that you have to get rid of. Just search for tail recursion and you will find what you need. In recursive algorothms reducing the number of jumps between functions or optimizing is done by minimizing the number of recursive jumps
29th Aug 2018, 2:59 PM
Paul