MHB Why is the runtime of Merge Sort O(n log n)?

  • Thread starter Thread starter find_the_fun
  • Start date Start date
  • Tags Tags
    Runtime Sort
AI Thread Summary
The discussion centers on the runtime complexity of the merge sort algorithm, specifically T(n) = nb + cn log(n). The confusion arises regarding why this is classified as O(n log n). It is clarified that for sufficiently large n (n > n0, where n0 is greater than the logarithm's base), the terms can be simplified. The dominant term in the expression is cn log(n), which grows faster than nb for large n. Therefore, the overall runtime can be expressed as being bounded by a constant multiple of n log(n), confirming that merge sort operates within O(n log n) complexity due to the constants b and c not affecting the growth rate as n increases.
find_the_fun
Messages
147
Reaction score
0
For megre sort alogirthm the runtime is T(n)=nb+cnlog(n). It's not quite clear to me why this is O(nlogn) is it because b and c are constants?
 
Technology news on Phys.org
find_the_fun said:
For megre sort alogirthm the runtime is T(n)=nb+cnlog(n). It's not quite clear to me why this is O(nlogn) is it because b and c are constants?

It is because for \(n>n_0\) where \(n_0>0\) is greater than the base of the logarithm (so \( \log(n)>1\) )
:

\[|T(n)|=|n \; b+c\; n \log(n)|<|b| \; n+|c|\; n \log(n)<|b|\; n \log(n)+ |c|\; n \log(n) = A\; n \log(n)\]

CB
 
Last edited:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top