• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Merge sort arguments??

Which elements in the array are the arguments int left and int right referring to?
The first and last indexes?

template <class type>
void mergesort(type a[], int left, int right)
{
  if(left<right)
    {
      int mid=(left + right)/2;
      mergesort(a, left, mid);
      mergesort(a, mid+1, right);
      merge(a,left,right);
    }
}
0
killer455
Asked:
killer455
  • 2
1 Solution
 
n_fortynineCommented:
>> The first and last indexes
... of the segment you're "sorting"
0
 
killer455Author Commented:
So basically if sorting an array of 10 elements you would pass
mergsort(Array, Array[0], Array[9])

correct?
0
 
n_fortynineCommented:
no, (Array, 0, 9); -> the *indexes* not the *values contained in the indexes*
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now