101 views

If both of the algorithms A and B need O(nlogn) time then they
both are equally efficient and finish in same amount of time.

TRUE OR FALSE

| 101 views
0
it should be true..
0

@SHUBHAM SHASTRI

what happens if we take A = O(n) and B = O(n log n), then also given statement is true?

Otherwise i can't take like that?

+2

for(i=0;i<n;i++)

{

count++;

}

time complexity is O(n) =O(n2) =O(n3)

But we generally denote with O(n) but it doesn't mean T(n) = O(n2) is wrong., it is also correct.

0
yes yes ..i got it ..you are correct ..
0
My doubt is that even if both algorithm has tightest upper bound as nlogn still it doesn't mean they will take exactly equal amount of time. It's approximation. Isn't it?
0
yes
0
So it should be false ?
+1
When w write O(nlogn) we don.t write the constant like O(nlogn+n) or O(nlogn*k) k is constant

Consider a real-life example the best case of Quicksort is faster than heap and merge because of constant associated with it

Measuring  the time complexity and the exact time are two different things, the asymptotic  notations gives us  approximation about the dependency of the number of steps with respect to the input size and the the exact time can be measured using the system clock .

The answer is false.

by Active (1.2k points)
0