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;
}
Title | # Comments | Views | Activity |
---|---|---|---|
Load and store *.pnm image file | 1 | 67 | |
How do I add zip/compression functionality to a C++ (Windows and Linux) application? | 3 | 83 | |
best sources to up-to-date in C++? | 8 | 55 | |
FMX TCameraComponent Problem | 2 | 10 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!