Re: Recursion Usage and Concepts - Newbie Question



Roedy Green schrieb:
On Mon, 15 Oct 2007 12:28:10 +0200, Christian <fakemail@xxxxxx> wrote,
quoted or indirectly quoted someone who said :

s Dynamic
programming needs some kind of object that holds results of earlier
computed values

I did all kinds of dynamic programming back in the days of Fortran
where you don't have recursion. It never dawned on me until now that
you could handle tracking the history with recursion.
I meant that if your Dynamic Programming based algorithm must somehow
provide the already calculated subproblems to each call of the function..

so either you could pass these as some object..
ex
public static Integer calc(Integer what, Map<Integer,Integer> subresults) {}

or you could use a calc object
class CalcObj {
private Map<Integer,Integer> subresults ...
public Integer calc(Integer what){}
}

I don't see any reason why a dynamic programming algorithm shouldn't
also use recursion if the problem is predestined for recursion but
without dynamic programming to hard to solve .. i.e fibonacci(again bad
example as O(1) is possible)..
.



Relevant Pages

  • Re: Response to Karen and to Willem on recursive proofs
    ... > Could you give an example of a correctness proof involving recursion? ... // But since it can be seen by inspection of the loop termination condition ... // Recursion in programming is, of course, a subroutine calling itself. ...
    (comp.programming)
  • Re: CAS, Lambda Calculus, Continuation and Functional Programming
    ... There are no expressions in Fortran or Pascal??! ... expressions are programming language constructs that return a value. ... > languages don't have recursion. ...
    (sci.math.symbolic)
  • Re: Another way to do x^n
    ... think carefully about writing code readable by folks who aren't Forth ... But the Forth programming culture is one of egotistical cleverness, ... Very handy for things like parsers. ... But there are enormous application areas where recursion is of no advantage, and its employment just obfuscates the code. ...
    (comp.lang.forth)
  • Re: This one goes to 11
    ... programming language and have it immediately executed during debugging. ... and especially tail recursion. ... Common Lisp cover all the important cases in a convenient, ...
    (comp.lang.lisp)
  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... > recursion to define an ordered set, that does not imply (as you imply ... programming in something like Java. ... >>> abandon Java in favour of a toy language that is limited to them and no ...
    (comp.programming)