+ 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

4th May 2019, 4:57 PM
Seniru
Seniru - avatar
18 Antworten
+ 19
• Algorithm Design Canvas — https://www.hiredintech.com/algorithm-design
4th May 2019, 6:29 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 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!
5th May 2019, 9:51 AM
Danijel Ivanović
Danijel Ivanović - avatar
5th May 2019, 8:33 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 10
~ swim ~ that was a good one bro, thanks for that, but I need to re-read again and again
4th May 2019, 5:36 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 10
thanks again ~ swim ~ , will definitely learn more from you in the near future
4th May 2019, 5:41 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 8
Algorithm complexity (a friendly intro): http://discrete.gr/complexity/
5th May 2019, 7:44 PM
Haris
Haris - avatar
+ 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
4th May 2019, 10:20 PM
Edison
Edison - avatar
+ 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?
5th May 2019, 9:13 AM
Seniru
Seniru - avatar
+ 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 👍
5th May 2019, 10:19 AM
Seniru
Seniru - avatar
+ 5
~ swim ~ thanks! it helped a lot 👍
5th May 2019, 2:18 PM
Seniru
Seniru - avatar
+ 3
Nexus You just have to know how to work with logarithms,exponents,sigmas and some basic algebra. It isn't so hard.
5th May 2019, 9:50 AM
Mensch
Mensch - avatar
+ 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.
5th May 2019, 9:54 AM
Mensch
Mensch - avatar
+ 2
Simple answer, YOU'VE TO KNOW MATH, EXTREME XD
5th May 2019, 8:55 AM
Baltazarus
Baltazarus - avatar
+ 2
Astralis. Thanks man
5th May 2019, 10:00 AM
Baltazarus
Baltazarus - avatar
+ 1
Thank you so much dear... :-)
5th May 2019, 12:24 PM
Ravi Maurya
0
its very simple to calculate the complexity( its total steps taken to complete a process-1)
5th May 2019, 6:00 PM
ankit goyal
ankit goyal - avatar
0
am i right or not also please tell me about that
5th May 2019, 6:00 PM
ankit goyal
ankit goyal - avatar