##### Algorithms A and B spend exactly

Algorithms A and B spend exactly T_{A}(n) = 5nlog_{10}n and T_{B}(n) = 25n microseconds, respectively, for a problem of size n. Which algorithm is better in the Big-Oh sense?

(A) Algorithm A

(B) Algorithm B

(C) Both are equivalent

(D) No comparison can be made

Answer: B

Discuss

someone explain this

A = O(nlogn), B= O(n)

It is very trivial if you know the complexity concepts.

n=O(nlogn)

sir, but answer is given B

In Big Oh notation when we say algorithm A = O(B) , this means that A is asymptotically faster and hence more efficient than B as here we are considering time so less time means more efficient and if A = O(B) , it means that A is asymptotically less value than B and hence less time will be consumed as far as A is concerned.

In this T

_{b}(n) = 25n means O(n) and T_{a}(n) = 5nlogn means O(nlogn).Obviously n < nlogn and hence n = O(nlogn)

⇒T

_{b}(n) = O(T_{a}(n))In other words T

_{b}(n) denotes less time consumption in this case as compared to T_{a}.Hence T_{b}is better algo as compared to T_{a}.Hence , B is the correct option.