Niclas Alexandersson edited dynamic.tex  about 10 years ago

Commit id: 990e670ab51bc2a53b111e1b3b7e1b10bcf7df4c

deletions | additions      

       

\subsection{Dynamic programming}  \begin{verbatim}  function maxReturn(i, x) begin  initialise mem to -1  return mr(i, x, 0) x)  end  function mr(i, x, a) x)  begin if mem[i,x] mem[i, x]  != -1 then if i = 0 then  let mem[i,x] = 0  else if x = return  0 then end  let mem[i,x] m  = 0 else for a in [0, x] loop  let mem[i,x] m  = max(g(a + 1) + mr(i, x - 1, a + 1), max(m,  g(a) + mr(i - 1, x, 0)) x - a))  end  end  return mem[i,x] mem[i, x]  end  \end{verbatim}