Skip to main content
2 votes

Week 2 Merge Sort: Why is it assumed that the elements will be in order when they are merged?

Think of it this way. The unsorted list of n elements is broken into n lists of 1 element each. A one-element list is, by definition, sorted. Now, the merging begins. Pairs of lists are merged by ...
Cliff B's user avatar
  • 69k
1 vote

How to merge sort array of struct while maintaining relations between int array and char array

each instance of nameandnum is a complete object, when you do your merge sort you need to swap the whole objects not just the buffer field.
UpAndAdam's user avatar
  • 1,386
1 vote

The Merge sort Algorithm

First: O(n) is the same as O(n/2), as constant factors do not matter (O(n) means there's a factor so that runtime is always less than or equal that factor times n). But also, you're wrong with n/2 ...
Blauelf's user avatar
  • 21k
1 vote

Merge Sort running into infinite loop using recursion

Your first mergesort() call results in an infinite loop. beg < end will always evaluate to true as the value is not modified. Recursively calling mergesort() creates copies of those integers. Any ...
aquablitz11's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible