Tags:
create new tag
view all tags

Recursion

Merge sort

#include <iostream>
#include <vector>
using namespace std;
 
void display(vector<int> a);
void merge(vector<int> &a, int s, int e);
void merge_sort(vector<int> &iArray, int s, int e);

//The main function
int main() {
    vector<int> iArray = {2, 5, 6, 4, 7, 2, 8, 3, 9, 10};
    merge_sort(iArray, 0, iArray.size() - 1);
    //Print the sorted array
    display(iArray);
    return 0;
}
 
// Display a vector of ints
void display(vector<int> a) {
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

// The merge function
void merge(vector<int> &a, int s, int e) {

}

//The recursive merge sort function
void merge_sort(vector<int> &iArray, int s, int e) {

}

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2017-12-05 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback