How do we get order of an Algorithm?
The efficiency of algorithm is defined in terms "O" notation. I am clear to some extent but i have some doubts too.
If for a particular algorithm, i employ a "for" loop that loops once over all "n" numbers order is O(n), if twice we loop it becomes O(2n), if a "for" loops inside another "for" loop it becomes O(n^2).
My doubt is how do they get O(n log n) or O(n^2 log n) ?? That is, am not clear how do they chip in this "log" ??
For example "Merge sort" algorithm is O(n log n). How do we get these numbers (log)?
Thanks in advance for helping 😀
Regards