How to judge the relative efficiency of algorithms given runtimes as functions of 'n'?

Posted by Lopa on Stack Overflow See other posts from Stack Overflow or by Lopa
Published on 2010-03-23T17:11:19Z Indexed on 2010/03/26 5:33 UTC
Read the original article Hit count: 357

Filed under:
|

Consider two algorithms A and B which solve the same problem, and have time complexities (in terms of the number of elementary operations they perform) given respectively by

a(n) = 9n+6

b(n) = 2(n^2)+1

(i) Which algorithm is the best asymptotically?

(ii) Which is the best for small input sizes n, and for what values of n is this the case? (You may assume where necessary that n>0.)

i think its 9n+6. guys could you please help me with whether its right or wrong?? and whats the answer for part b. what exactly do they want?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about homework