Solved

Merge sort arguments??

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

758 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

23 Experts available now in Live!

Get 1:1 Help Now