programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Timing Complexity

Jacob Sonia
Ranch Hand
Posts: 183
Hi all,

I am really not able to understand how exactly do we calculate the O(n) of any algorithm. suppose my algorithm has a complexity of 3n/2 + 1 then how would i say what is O(n) of it. Please help me understand that. any pointers would be useful

Campbell Ritchie
Marshal
Posts: 56529
172
Try this link, which I hope will give you Niklaus Wirth's algorithms book. As far as I know you can legally download it as a .pdf. There is bound to be a chapter about complexity and about the big-O notation.

Ulrika Tingle
Ranch Hand
Posts: 92
Jacob Sonia wrote:
I am really not able to understand how exactly do we calculate the O(n) of any algorithm. suppose my algorithm has a complexity of 3n/2 + 1 then how would i say what is O(n) of it. Please help me understand that. any pointers would be useful

The Ordo system is concerned with the overall complexity. In an expression like 3n/2 + 1 you pick the worst contribution and remove the multiplicative constant. This gives you O(n). This tells you that the complexity is linear. I means that if you double the data input, the execution time will double. Any expression describing a line (is of the form k*n + m) belongs to the same category, that is O(n).

 With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.