Linear time - Biblioteka.sk

Upozornenie: Prezeranie týchto stránok je určené len pre návštevníkov nad 18 rokov!
Zásady ochrany osobných údajov.
Používaním tohto webu súhlasíte s uchovávaním cookies, ktoré slúžia na poskytovanie služieb, nastavenie reklám a analýzu návštevnosti. OK, súhlasím


Panta Rhei Doprava Zadarmo
...
...


A | B | C | D | E | F | G | H | CH | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Linear time
 ...
Graphs of functions commonly used in the analysis of algorithms, showing the number of operations N as the result of input size n for each function

In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, supposing that each elementary operation takes a fixed amount of time to perform. Thus, the amount of time taken and the number of elementary operations performed by the algorithm are taken to be related by a constant factor.

Since an algorithm's running time may vary among different inputs of the same size, one commonly considers the worst-case time complexity, which is the maximum amount of time required for inputs of a given size. Less common, and usually specified explicitly, is the average-case complexity, which is the average of the time taken on inputs of a given size (this makes sense because there are only a finite number of possible inputs of a given size). In both cases, the time complexity is generally expressed as a function of the size of the input.[1]: 226  Since this function is generally difficult to compute exactly, and the running time for small inputs is usually not consequential, one commonly focuses on the behavior of the complexity when the input size increases—that is, the asymptotic behavior of the complexity. Therefore, the time complexity is commonly expressed using big O notation, typically , , , , etc., where n is the size in units of bits needed to represent the input.

Algorithmic complexities are classified according to the type of function appearing in the big O notation. For example, an algorithm with time complexity is a linear time algorithm and an algorithm with time complexity for some constant is a polynomial time algorithm.

Table of common time complexities

The following table summarizes some classes of commonly encountered time complexities. In the table, poly(x) = xO(1), i.e., polynomial in x.

Name Complexity class Time complexity (O(n)) Examples of running times Example algorithms
constant time 10 Finding the median value in a sorted array of numbers.

Calculating (−1)n

inverse Ackermann time Amortized time per operation using a disjoint set
iterated logarithmic time Distributed coloring of cycles
log-logarithmic Amortized time per operation using a bounded priority queue[2]
logarithmic time DLOGTIME , Binary search
polylogarithmic time
fractional power where , Range searching in a kd-tree
linear time n, Finding the smallest or largest item in an unsorted array.

Kadane's algorithm. Linear search

"n log-star n" time Seidel's polygon triangulation algorithm.
linearithmic time , Fastest possible comparison sort

Fast Fourier transform.

quasilinear time Multipoint polynomial evaluation
quadratic time Bubble sort, Insertion sort, Direct convolution
cubic time Naive multiplication of two matrices

Calculating partial correlation.

polynomial time P