Mazdak Farrokhzad added dynamic.tex  about 10 years ago

Commit id: cef0de029e1352418ba0ac6ce2d4301c760f6536

deletions | additions      

         

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