Answered step by step
Verified Expert Solution
Question
1 Approved Answer
using c void knapsack3 (intn const int pl. const int w int W int& mazprofit) priority queue of node PO node u, /Initialize PO to
using c
void knapsack3 (intn const int pl. const int w int W int& mazprofit) priority queue of node PO node u, /Initialize PO to be initialize (PQ); u. Ievel = 0: u, profit-o: v.we ight = 0; rn a profit = 0; U, bond = bound(r); insert(PQ. ) // empty / Initialize to be the // root. / Remove node with // best bound. // Check if node is still // promising while (1empty(PO)) remove (PQ. ) if (u, bound maxprofit) u. level-e.leeel + 1: u. weighte.weight +wlu. levell: Set u to the child u. profit-.profit +piu. levell: I/ that Includes the // next item. if (u. weight W&& u.profit > maxprofit) marprofit-u.profit; u.bound bound(u): ir (u. bound maxprofit) insert(Pg) u. weight-w.weight u. profit.profit: u. boundbound(u) ir (u.bound maxprofit) // Set u to the child // that does not include // the next item insert(P
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started