Jump to content

Merge sort run time

Featured Replies

I am confused as to why merge sort for a list of size 2^n takes n steps.

If you have n=4 lists 3,9,8,10 and you sort from least to greatest:
3 9 8 10
(3,9) (8,10) 2 work to compare 3 with 9 and 8 with 10.
(3,8,9,10) 3 work to compare 3 with 8, 8 with 9, and 9 with 10.

That's a total of 5 work, not 4. Every definition out there says it takes 4 steps to merge when it obviously takes 5 steps in the example given. Why is that?

Edited by DylsexicChciken

  • Author

Edit, first line should read: I am confused as to why merge sort for a list of size 2^k=n takes n steps.

Edited by DylsexicChciken

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.