Читать книгу The Self-Taught Computer Scientist - Cory Althoff - Страница 21

Logarithmic Time

Оглавление

Logarithmic time is the second most efficient time complexity. An algorithm takes logarithmic time when its run time grows in proportion to the logarithm of the input size. You see this time complexity in algorithms such as a binary search that can discard many values at each iteration. If this is not clear, don't worry, because we will discuss this in depth later in the book. You express a logarithmic algorithm in big O notation as O(log n).

Figure 1.2 shows what it looks like when you plot a logarithmic algorithm.

The required number of steps grows more slowly in a logarithmic algorithm as the data set gets larger.


Figure 1.2 Logarithmic complexity

The Self-Taught Computer Scientist

Подняться наверх