₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,328,966 members, 8,438,178 topics. Date: Friday, 03 July 2026 at 05:22 AM

Toggle theme

Time Complexity Guide For Developers - A Short Primer - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingTime Complexity Guide For Developers - A Short Primer (940 Views)

1 Reply

Time Complexity Guide For Developers - A Short Primer by harryobas(op): 2:04pm On Apr 16, 2019
As a developer, time complexity is one of the most interesting concepts you can learn from computer science, and you don’t need a degree to understand it!


It’s interesting because it helps you see why a particular algorithm or program may be slow and what can you do to make it faster.

Slow vs Fast

Is sorting 1 million numbers in 150ms (milliseconds) slow or fast? I think that’s pretty fast, but this is not the question that time complexity is trying to answer. We want to know how an algorithm is going to perform as the “input size” grows.

When we talk about “input size” we are talking about the arguments for the function or method. If a method takes one string as an argument then that’s the input, and the string’s length is the input size.

Big O Notation

With Big O notation we can classify algorithms according to their performance. Some examples of this notation are shown below:

1. O(1) - In this case, O(1) represents a “constant time” algorithm. That means that the algorithm will always take the same time to finish its work, regardless of how much work it has to do.

2. O(n) - In this case, O(n) represents "linear time". Where “n” represents the size of the input (string size, array size, etc). This means that the algorithm will finish its work in a 1:1 relation to input size, so doubling the input size will also double the time it takes to complete the work.

Happy Coding smiley
Re: Time Complexity Guide For Developers - A Short Primer by abula112(m): 7:32pm On Apr 16, 2019
harryobas:
As a developer, time complexity is one of the most interesting concepts you can learn from computer science, and you don’t need a degree to understand it!


It’s interesting because it helps you see why a particular algorithm or program may be slow and what can you do to make it faster.

Slow vs Fast

Is sorting 1 million numbers in 150ms (milliseconds) slow or fast? I think that’s pretty fast, but this is not the question that time complexity is trying to answer. We want to know how an algorithm is going to perform as the “input size” grows.

When we talk about “input size” we are talking about the arguments for the function or method. If a method takes one string as an argument then that’s the input, and the string’s length is the input size.

Big O Notation

With Big O notation we can classify algorithms according to their performance. Some examples of this notation are shown below:

1. O(1) - In this case, O(1) represents a “constant time” algorithm. That means that the algorithm will always take the same time to finish its work, regardless of how much work it has to do.

2. O(n) - In this case, O(n) represents "linear time". Where “n” represents the size of the input (string size, array size, etc). This means that the algorithm will finish its work in a 1:1 relation to input size, so doubling the input size will also double the time it takes to complete the work.

Happy Coding smiley
is that all?
Re: Time Complexity Guide For Developers - A Short Primer by ANTONINEUTRON(m): 9:08pm On Apr 18, 2019
There is also quadratic, logarithmic,exponential,polynomial and many more complexities.

My work diz semester.
Data structures and algorithm is really cool tho!
1 Reply

For Developers, How Did You Get Your First Remote Job And What Was The Pay.How To Make Money In Game Development For Developers.Explain Time Complexity To Me Like A 5 Year Old234

Magento 2 Custom Cart & Checkout Messages Extension By FmeextensionsTech Cofounder Needed(technical)Brokenness And Programming