reduce loop


#1

Can any one tell me how we can reduce loops except using recurssion … if I’m getting O(n^3) how can we reduce it.
In C,C++,JAVA


#2

It depends upon the problem . Moreover it is not always necessary to reduce the complexity . It may be possible for that type of problem to have the best solution of complexity O(n^3) . It may also be possible that the problem setter intends you to solve with this complexity and do so , he set up the test cases low enough .


#3

thanks… bt… if we get test case and 2D array problem… how will you do this in O(n^2).
some time I need this to set it to O(n^2) instead of O(n^3). so pls tell me any possible way.


#4

As I said before , it depends upon question . A complete search algorithm is sometimes what is needed . If you provide the question , may be I can help .