Recurrence equation calculation I have a recurrece equation



Changed notations:
$\qquad\displaystyle G(W) = \max \{ G(W - s_i) + v_i \mid 0 \leq i \leq n, w_i \leq W \}$,

I am not sure if I understand $\ w_i $ correctly. 

On each iteration my $ w_i \leq W $ . So my $ w_i $ will be previous $ W-s_i $ since G takes one argument?
Here is pseudocode for computing your function:


  Parameters:
  
  
  Integer $n$
  Arrays $W,V,S$ of length $n$
  
  
  function G(w):
  
  
  If $w = 0$, return $0$
  Let $\mathrm{max} \gets -\infty$
  For $i$ from $1$ to $n$:
  
  If $W[i] \leq w$:
  
  
  
  Let $x \gets G(w-S[i])+V[i]$
  
  
  
  
  If $x &gt; \mathrm{max}$, let $\mathrm{max} \gets x$
  
  
  Return $\mathrm{max}$
  


I used the notation $W[i],V[i],S[i]$ rather than $w_i,v_i,s_i$.