+ 13
How to calculate the complexity of a algorithm.
While I was doing some coding challenges I found that they were asking for an algorithm with an O(n) complexity. I know about the big-O noatation (not all) but what I really need to know is how to calculate them. I searched a lot in sololearn and stackovwrflow and I finally met with this 1 https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm In that question I found that the asker uses a method for calculating the complexity. {1+(N+1)+N} = 2N+2 My question is is that way correct and how to calculate the complexity of an algorithm. Thanks
24 odpowiedzi
+ 19
• Algorithm Design Canvas — https://www.hiredintech.com/algorithm-design
+ 18
Sεηιrυ ραsαη 👍
You are welcome friend!
I will try to find more resources for explanation, I know what you need, so will try my best!
+ 12
• Determining the big-O runtimes of these different loops?
https://stackoverflow.com/questions/11094330/determining-the-big-o-runtimes-of-these-different-loops
+ 10
~ swim ~ that was a good one bro, thanks for that, but I need to re-read again and again
+ 10
thanks again ~ swim ~ , will definitely learn more from you in the near future
+ 8
Algorithm complexity (a friendly intro):
http://discrete.gr/complexity/
+ 6
The most common metric for calculating time complexity is Big O notation. This removes all constant factors so that the running time can be estimated in relation to N as N approaches infinity. Find some more https://stackoverflow.com
+ 5
Biraj ~ swim ~ *AsterisK* Danijel Ivanović thanks a lot for those valuable resources. But still one of my problems hasn't solved. Is that method (the thing like {1+(N+1).. }) a valid way?
Nexus how would knowing math only help in this situation?
+ 5
~ swim ~ I know that thing already. Anyway thanks for sharing them.
But what I really need to know is how those numbers (like n^2, logN) came. I got some knowledge about those numbers from those resources you gave me. But still I'm stucked with them.
Danijel Ivanović and others thanks for spending your time on this 👍
+ 5
~ swim ~ thanks! it helped a lot 👍
+ 3
Nexus You just have to know how to work with logarithms,exponents,sigmas and some basic algebra. It isn't so hard.
+ 3
Sεηιrυ ραsαη if you need an in depth explanation,Just check out the wikipedia page on big-O notation. It has explanations on analyzing the running time of algorithms.
+ 2
Simple answer, YOU'VE TO KNOW MATH, EXTREME XD
+ 2
Astralis. Thanks man
+ 1
Thank you so much dear...
:-)
0
its very simple to calculate the complexity( its total steps taken to complete a process-1)
0
am i right or not also please tell me about that