Question: sequence longest_increasing_powerset(const sequence& A) { const size_t n = A.size(); sequence best; std::vector stack(n+1, 0); size_t k = 0; while (true) { if (stack[k] <

sequence longest_increasing_powerset(const sequence& A) {

const size_t n = A.size();

sequence best;

std::vector stack(n+1, 0);

size_t k = 0;

while (true) {

if (stack[k] < n) {

stack[k+1] = stack[k] + 1;

++k;

} else {

stack[k-1]++;

k--;

}

if (k == 0) {

break;

}

sequence candidate;

for (size_t i = 1; i <= k; ++i) {

candidate.push_back(A[stack[i]-1]);

}

// TODO

// write the if statement to test whether candidate determines

// an increasing sequence AND has a size larger than the size

// of the current best

// if both conditions are satisfied, then stored candidate in best

}

return best;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!