What is the big-O of the function (log n)^k

Any function whose runtime has the form (log n)k is O((log n)k). 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)2). Functions with this growth rate are called polylogarithmic. By the way, typically (log n)k is written as logk n, so the above … Read more

Big Oh for (n log n)

Explanation: The outer for loop should be clear; it is executed n times. Now to the inner loop. In the inner loop, you take n and always divide it by 2. So, you ask yourself: How many times can I divide n by 2? It turns out that this is O (log n). In fact, the base of log is 2, but in Big-O notation, we remove … Read more

Order functions by growth rate

EDIT: I’ve revised my answer based on the comments I’ve got this HW question which asks me to order a list of functions by their growth rate. The question also asks to indicate which ones have the same growth rate. Here are the functions: N sqrt(N) N^1.5 N^2 N log N N log log N … Read more