Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

n log n is O(n)?

Tags:

I am trying to solve this recurrence

T(n) = 3 T(n/2) + n lg n ..

I have come to the solution that it belongs to masters theorem case 2 since n lg n is O(n^2)

but after referring to the solution manual i noticed this solution that they have

enter image description here

The soluttion says that n lg n = O ( n ^(lg 3 - e)) for e between 0 and 0.58

so this means n lg n is O(n) .. is this right? Am i missing something here?

Isn't nlgn O(n^2) ?

like image 398
Wael Awada Avatar asked Oct 20 '11 03:10

Wael Awada


People also ask

What does O'n log n mean?

O(log N) basically means time goes up linearly while the n goes up exponentially. So if it takes 1 second to compute 10 elements, it will take 2 seconds to compute 100 elements, 3 seconds to compute 1000 elements, and so on. ​It is O(log n) when we do divide and conquer type of algorithms e.g binary search.

What is bigger O of n or O of log n?

Clearly log(n) is smaller than n hence algorithm of complexity O(log(n)) is better. Since it will be much faster.

What is log n equal to?

logarithm, the exponent or power to which a base must be raised to yield a given number. Expressed mathematically, x is the logarithm of n to the base b if bx = n, in which case one writes x = logb n. For example, 23 = 8; therefore, 3 is the logarithm of 8 to base 2, or 3 = log2 8.

Is O'n less than O'n log n?

Yes for Binary search the time complexity in Log(n) not nlog(n). So it will be less than O(n). But N*Log(N) is greater than O(N).


1 Answers

This will explain things better enter image description here

like image 145
Sreenath Nannat Avatar answered Dec 15 '22 00:12

Sreenath Nannat