Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含两个操作的算法。第一次操作的运行时间是 O(n),第二次操作的运行时间是 O(log n)。在这种情况下,完整算法的运行时间是多少?会是 O(n) 还是 O(n) + O(log n) ?
O(n + log(n)) = O(n)
您的时间复杂度将是 O(n)
http://en.wikipedia.org/wiki/Big_O_notation
总时间为O(n) + O(logn) = O(n)。所以这是O(n)
O(n) + O(logn) = O(n)
O(n)
O(logn)与O(n)N 呈指数下降有关,所以它是O(n)。
O(logn)