La complexité linéaire est un terme utilisé dans l'informatique and algorithm analysis to describe the efficiency of an algorithm. An algorithm is said to have linear complexity, denoted as O(n), when its execution time or the number of operations it performs is directly proportional to the size of the input data. This means that if the input size doubles, the execution time also doubles, resulting in a straightforward and predictable performance characteristic.
La complexité linéaire est souvent rencontrée dans algorithms that process each element of a dataset exactly once. For instance, a simple loop that iterates through an array to calculate the sum of its elements has linear complexity. As a result, linear complexity is generally considered efficient, especially when compared to higher complexity classes such as quadratic (O(n²)) or exponential (O(2^n)) algorithms.
In practical applications, algorithms with linear complexity are often preferred when dealing with large datasets, as they can handle significant amounts of information without substantial increases in processing time. However, it is essential to note that while linear complexity is efficient, it may not always be the optimal choice depending on the specific requirements of a task or the characteristics of the data involved.