Solved

Merge sort arguments??

Posted on 2003-10-28
3
212 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 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

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!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

690 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