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.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top