Python icon indicating copy to clipboard operation
Python copied to clipboard

Merge sort best & average case O(n)?

Open sfdye opened this issue 8 years ago • 11 comments

https://github.com/TheAlgorithms/Python/blob/master/README.md#merge Shouldn't it be O(n log n).

The Java repo is correct though: https://github.com/TheAlgorithms/Java#merge

sfdye avatar Sep 13 '18 03:09 sfdye

it's O(n log n ) only.

pandyamarut avatar Sep 13 '18 08:09 pandyamarut

#342 I changed the readme and created a pull request

hasangokdag avatar Sep 13 '18 11:09 hasangokdag

It is O(n*log(n)) for best, average and worst case. Where, n:size of the array under consideration.

vishkothari96 avatar Sep 18 '18 08:09 vishkothari96

Yes! It should be O(n*log(n)) for every case i.e. best case, average case, worst case.

sumitkumar22299 avatar Sep 19 '18 15:09 sumitkumar22299

Are you pointing out that there should be a "" between n and log(n)? like O(n log(n)) vs O(nlog(n))?

In readme file Merge, Quick and Shell is also using one space as multiplication instead of "*". Thats why I also used it that way in the PR.

hasangokdag avatar Sep 21 '18 20:09 hasangokdag

@hasangokdag No. In the master, best & average are O(n) which are simply incorrect and misleading.

sfdye avatar Sep 22 '18 01:09 sfdye

Hi @sfdye , @hasangokdag has corrected precisely what you are saying in his commit. Look at his commit: https://github.com/TheAlgorithms/Python/pull/342/commits/ce3e6787f4df7fa198881b1dfa80c58a5c7afbb5 But his PR is still open, please be patient and let the repo owners merge his PR.

piyush01123 avatar Sep 22 '18 04:09 piyush01123

@piyush-kgp Yeah I am aware of the PR. It should get high priority as this simple typo could fail someone's interview.

sfdye avatar Sep 22 '18 04:09 sfdye

Yes. you are right. Just noticed that this thread is 9 days old. Apologies.

piyush01123 avatar Sep 22 '18 04:09 piyush01123

Thanks @hasangokdag

AnshulMalik avatar Sep 28 '18 04:09 AnshulMalik

Finally this is merged. Cheers 👍

sfdye avatar Sep 28 '18 04:09 sfdye