Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
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
Join the community of 500,000 technology professionals and ask your questions.