big o - Would this function be O(n^2log_2(n))? -


so given function 65536 n2 + 128 n log2n

and way o(n2 log2n) if

c = 65664, n0 = 2 n ≥ 2 since

c1 = 65536 n1 = 2 when 65536 ≤ c1*n2 and
c2 = 128 n2 = 1 when 128 ≤ c2*n

but number i've chosen constant seems bit high, there way check this?

o(65536 n2 + 128 n log2n) same o(n2 + n log2n) since can ignore multiplicative constants. o(n2 + n log2n) equal o(n2) since n2 grows faster n log2n.

also, way, base of logarithms doesn't matter in big-o analysis. logarithms grow @ same rate. after all, log2n = log n / log 2, , multiplicative constants can factored out. can log n instead of log2n.

caveat: technically, true statement 65536 n2 + 128 n log2n ∈ o(n2 log2n) because big-o gives an upper bound, not strict one. o(n2) lower upper bound, if makes sense.

that said, should not have come o(n2 log2n). merely result of accidentally turning addition multiplication. rule of thumb, if have multiple things added inside big-o formula, have figure out 1 of them grows fastest , discard others.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -