Solved

Merge sort arguments??

Posted on 2003-10-28
3
208 Views
Last Modified: 2010-04-02
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
Comment
Question by:killer455
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
n_fortynine earned 25 total points
ID: 9637857
>> The first and last indexes
... of the segment you're "sorting"
0
 

Author Comment

by:killer455
ID: 9638652
So basically if sorting an array of 10 elements you would pass
mergsort(Array, Array[0], Array[9])

correct?
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9638718
no, (Array, 0, 9); -> the *indexes* not the *values contained in the indexes*
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now