Time Complexity

Why Trust Techopedia

What Does Time Complexity Mean?

Time complexity is a concept in computer science that deals with the quantification of the amount of time taken by a set of code or algorithm to process or run as a function of the amount of input.

Advertisements

In other words, time complexity is essentially efficiency, or how long a program function takes to process a given input.

Techopedia Explains Time Complexity

Time complexity is simply a measure of the time it takes for a function or expression to complete its task, as well as the name of the process to measure that time. It can be applied to almost any algorithm or function but is more useful for recursive functions. There is little point in measuring time complexity for applications such as fetching the username and password from a database for comparison or simply saving data whether it is 20 ms or 5 ms; that would be more in the line of access time. It has nothing to do with caring about its execution time, but rather that the difference is negligible. However, if there is a recursive function that may be called multiple times, determining and understanding the source of its time complexity may help shorten the overall processing time from, say, 600 ms to 100 ms.

Time complexity is expressed typically in the "big O notation," but there are other notations. This is a mathematical representation of the upper limit of the scaling factor for an algorithm and is written as O(Nn), with "N" being the number of inputs and "n" being the number of looping expressions. For example, we have the algorithm:




 numbers[] = {5,6,10,11,2};

foreach (number as number1)

{

 foreach(number as number2)

{

 statements;

 }

 }

There are five inputs in the "numbers" array, and the "foreach" loop is repeated twice. Therefore, exponential growth in processing time occurs as the number of inputs and the number of loops grow.

Advertisements

Related Terms

Margaret Rouse
Technology Specialist
Margaret Rouse
Technology Specialist

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.