Question
Implement Merge-Sort algorithm in mergeSort.cpp, where you are expected to implement two functions, merge() and mergeSort(). You are expected to call merge() within mergeSort(), and
Implement Merge-Sort algorithm in mergeSort.cpp, where you are expected to implement two functions, merge() and mergeSort(). You are expected to call merge() within mergeSort(), and you are not expected to declare/ implement other additional functions nor change the main() function.
#include
}
// using mergeSort to sort sub-array A[l..r] // l is for left index and r is right index of the // sub-array of A[] to be sorted void mergeSort(int A[], int l, int r) {
}
int main() { cout << "Please enter the length (number of elements) of the input array: "; int n; cin >> n; if(n <= 0) { cout << "Illegal input array length!" << endl; return 0; } int* A = new int [n]; cout << "Please enter each element in the array" << endl; cout << "(each element must be an integer within the range of int type)." << endl; for(int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started