Could you post your whole buildable program including test driver.
void merge(number_sequence S, index mid) { // Solve the Merge problem.
index n =size(S);
number* p = new number[n];
number_sequence A, B;
A.init(p, mid);
B.init(p+mid, n-mid);
copy(A, subseq(S, 1, mid));
copy(B, subseq(S, mid+1, n));
index a=1, b=1;
for (index k = 1; k <= n; ++k) {
if (a <= mid and b <= n-mid)
if (A[a] < B[b]) S[k] = A[a++];
else S[k] = B[b++];
else if (a <= mid)
S[k] = A[a++];
else
break;
}
delete p; // Deallocate work space.
}
for (index k = 1; k <= n; ++k) {
if (a <= mid and b <= n-mid)
if (A[a] < B[b]) S[k] = A[a++];
else S[k] = B[b++];
else if (a <= mid)
S[k] = A[a++];
else
break;
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
xamarin c# deserialize Json containing nested object | 2 | 80 | |
Using Diagnostic tools in VS2015: Unresoved allocations | 19 | 63 | |
Problem with SqlConnection | 4 | 159 | |
Windows Updates failing due to Diskpart not configured correctly | 8 | 103 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
22 Experts available now in Live!