?
Solved

Merge sort arguments??

Posted on 2003-10-28
3
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
n_fortynine earned 100 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

Independent Software Vendors: 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!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

770 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