You are here:

C++/Merge Sort Question

Advertisement


Question
Implement the mergesort algorithm in C++ as it sorts the following array into ascending order. List the calls to mergesort and to merge in the order in which they occur.

                        10, 40, 20, 12, 30, 15
Here is how i mad the human merge.

10,40,20,12                     30,15

10,40    20, 12                  30,15

10,40   20,12                     30,15

10,40   12,20                     15,30

10,12,20,40               15,30

10,12,15,20,30,40

How would i go about implementing this solution in c++?.
What does the question mean list the calls to merge sort?.

Answer
> How would i go about implementing this solution in c++?.

see: http://en.wikipedia.org/wiki/Merge_sort

> What does the question mean list the calls to merge sort?.

Merge sort is usually implemented recursively. So this means trace all the recursive calls to the merge sort function.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++09. i would not answer questions about gui and web programming.

Experience

over 15 years

Education/Credentials
post graduate engineer

©2012 About.com, a part of The New York Times Company. All rights reserved.