# Time Complexity

posted 2 years ago

Suppose i have written a method like this

**hi All...**

Suppose i have written a method like this

*then what will be time complexity of my code...according to me it will be O(nlgn + n^2) ...is it correct ?*

The Only way to learn is ...........do!

Visit my blog http://inaved-momin.blogspot.com/

Ulf Dittmer

Rancher

Posts: 42968

73

posted 2 years ago

- 1

in Big-O notation, you ignore all but the most significant term. so when you look at O(nlgn + n^2), the (n lg n) term grows so much slower than n^2, as n -> infinity, it really doesn't count for much. Therefore, you can safely ignore it.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

posted 2 years ago

- 1

thanks ..appreciate your input....

so conclusion is ..its O(n^2) ....

so conclusion is ..its O(n^2) ....

The Only way to learn is ...........do!

Visit my blog http://inaved-momin.blogspot.com/