什么是大O的功能

什么是大O的功能

本文介绍了什么是大O的功能(log n)的^ 2 + LOGN的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是功能的大O的复杂性(log n)的对任意k?

What is the big-O complexity of the function (log n) for any k?

推荐答案

,其运行时的任何函数的形式(log n)的为O((log n)的)。这一增长速度的函数被调用的 polylogarithmic。

Any function whose runtime has the form (log n) is O((log n)). This expression isn't reducable to any other primitive function using simple transformations, and it's fairly common to see algorithms with runtimes like O(n (log n)). Functions with this growth rate are called polylogarithmic.

顺便说一句,通常(log n)的写成日志 N,所以上述算法将有运行时为O(n日志ñ。在你的情况,功能日志 N +日志N是为O(log N)。

By the way, typically (log n) is written as log n, so the above algorithm would have runtime O(n log n. In your case, the function log n + log n would be O(log n).

然而,与表单日志运行时任何功能(正)具有运行时间为O(log n)的,假设k为常数。这是因为的log(n )= K日志N使用对数的身份,并且k日志n为0(log n)的,因为k是常数。您应该谨慎,不要盲目断定的算法是O(日志(N ))为O(log n)的,虽然,如果k是一个参数的函数或依赖于N,正确的大O计算将o在这种情况下,(K log n)的。

However, any function with runtime of the form log (n) has runtime O(log n), assuming that k is a constant. This is because log (n) = k log n using logarithm identities, and k log n is O(log n) because k is a constant. You should be careful not to blindly conclude that an algorithm that is O(log (n)) is O(log n), though; if k is a parameter to the function or depends on n, the correct big-O computation would be O(k log n) in this case.

这取决于你的工作环境中,你有时会看到乐谱O(F(N))的意思O(F(N)日志 N)为一些常数k。这有时被称为soft-O"并用于环境中对数项是无关的。在这种情况下,你可以说,这两个功能是O(1),虽然这种用法是不是在简单的算法分析常见的(事实上,维基百科之外,我所看到的这种用precisely一次)。

Depending on the context in which you're working, you sometimes see the notation Õ(f(n)) to mean O(f(n) log n) for some constant k. This is sometimes called "soft-O" and is used in contexts in which the logarithmic terms are irrelevant. In that case, you could say that both functions are Õ(1), though this usage is not common in simple algorithmic analysis (in fact, outside of Wikipedia, I have seen this used precisely once).

希望这有助于!

这篇关于什么是大O的功能(log n)的^ 2 + LOGN的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 17:07