This job selection problem finds the best days to work for a job where **if you work one day, you cant work the day before or after.**

34 Views Asked by At

This job selection problem finds the best days to work for a job where if you work one day, you cant work the day before or after. The self reduction for this problem is given below:

$ JS(P[1,2,........,n])= \begin{bmatrix} 0 , \ \ \ if \ \ n<0 \\ P[1] , \ \ \ if \ n=1 \\ max\{P[1],P[2] \} , \ if \ \ \ n=2 \\ max\{ JS (P[1,2,......,n-2] )+P[n],JS (P[1,2,.., n-1 ]) \}, \ \ \ if \ \ n>2 \end{bmatrix} $

Then how would the self reduction change if the problem changed to $ \to \ $ you can work 2 days in a row but you cant work the day before or after ?

Answer:

The given self -reduction was for the work of $ \ 1 \ \ day \ $.

We have to find same the formula for $ 2 \ \ days \ $.

According to me the self-reduction for $ \ 2 \ \ days \ $ work becomes

$ JS(P[1,2,........,n])= \begin{bmatrix} 0 , \ \ \ if \ \ n<0 \\ P[1] , \ \ \ if \ n=1 \\ P[1]+P[2] , \ if \ \ \ n=2 \\ max\{P[1]+P[2], \ P[1]+P[3], \ P[2]+P[3] \}, \ \ if \ \ n=3 \\ max\{ JS (P[1,2,......,n-2] )+P[n],JS (P[1,2,.., n-1 ]) \}, \ \ \ if \ \ n>3 \end{bmatrix} $

Am I right ? Is there any help ?

1

There are 1 best solutions below

0
On

Not quite: the last term in the self-reduction still forces you to alternate days on and off. There should be three possible cases - count backwards from the last day you don't work.