title: recursive tree for the cutting Rod prob set
body: <p>I have the a recursive solution to the cutting rod (dynamic problem). The problem is described <a href="http://www.geeksforgeeks.org/dynamic-programming-set-13-cutting-a-rod/" rel="nofollow">here</a>. 
  If you run this code you notice that when the outer for loop iterates the recursive function doesn't run again (see 'i' doesn't get printed again for 0 and 1). I am wondering whether Python memorizes the result of the recursion from the previous iteration? I thought it would have to do the recursive call each time I iterate i, but it doesn't seem like it. </p>
  
  <pre><code>def cutRod(n, prices):
      if n &lt;= 1:
          return prices[0]
      max_val = 0
      for i in range(n):
          print i, max_val
          max_val = max(max_val, prices[i] + cutRod(n-i-1, prices))
          print max_val
      return max_val
  
  prices = [2,5,3]
  n = len(prices)
  print cutRod(n,prices)
  </code></pre>