It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.
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;
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Could you post your whole buildable program including test driver.