Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

This question already has an answer here:

I have Java function as input and want to get it's order for example O( n ) I search in the internet very hard but didn't find any thing can help me, is there any algorithms or package may help me.

share|improve this question

marked as duplicate by Juho, Luke Mathieson, D.W., frafl, András Salamon Feb 17 at 10:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
basically you look at the loops and nested loops. if you write out what its doing in pseudocode it would help. also so many std algorithms have known complexity eg sorting or whatever, it may just fit into an existing algorithm. so, "need more info" –  vzn Feb 16 at 2:10

1 Answer 1

No. There's no algorithm to analyze the asymptotic complexity of a piece of code given as input. Being able to do that would tell you whether the code halted and that's undecidable.

share|improve this answer
    
However, there might be an algorithm which works in many useful cases, for example when the functions are "primitive recursive" or with known complexity. –  Yuval Filmus Feb 15 at 5:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.