Solution:
Let's calculate the effective profit first
P1= 12/40 = 0.3
P2= 3/20 = 0.15
P3= 4/10= 0.4
P4= 20/60= 0.333
First, we will pick the most profitable item
that is P3
but we can see any combination of P1 P2 and P3 won't be as effective as if P4 is selected alone
so P4 with the value 20 will be loaded
The optimal solution is P4 with the value 20
The running time is O(n^2)
If W= 70
then the optimal solution will be
P4, and P3, with the value 20+4 = 24
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
dynamic program ship tas port each ship tke hom ber of conterns and the oe iejd...