Western Governors University (WGU) ICSC2100 C949 Data Structures and Algorithms I Practice Exam

Question: 1 / 400

Which function's cost scales logarithmically with the input size?

O(n)

O(log n)

The function that scales logarithmically with the input size is O(log n). This notation indicates that as the size of the input (n) increases, the time or space complexity of the function increases at a rate proportional to the logarithm of n.

In practical terms, this means that even as the input size grows substantially, the increase in cost is relatively small, making logarithmic time complexity very efficient. A common example of an O(log n) operation is a binary search algorithm, which halves the input space with each step, thus requiring far fewer steps than would be required for linear or polynomial complexity in searching through a sorted array.

Other complexity notations, such as O(n), O(n^2), and O(nm), represent linear and polynomial relationships with the input size, which scale much more quickly than logarithmic complexity. Therefore, O(log n) stands out as the most efficient in terms of growth relative to input size.

Get further explanation with Examzify DeepDiveBeta

O(n^2)

O(nm)

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy