Re: Recursion Usage and Concepts - Newbie Question
- From: Christian <fakemail@xxxxxx>
- Date: Mon, 15 Oct 2007 20:19:52 +0200
Roedy Green schrieb:
On Mon, 15 Oct 2007 12:28:10 +0200, Christian <fakemail@xxxxxx> wrote,I meant that if your Dynamic Programming based algorithm must somehow
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.
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)..
.
- References:
- Recursion Usage and Concepts - Newbie Question
- From: Taria
- Re: Recursion Usage and Concepts - Newbie Question
- From: Christian
- Re: Recursion Usage and Concepts - Newbie Question
- From: Roedy Green
- Recursion Usage and Concepts - Newbie Question
- Prev by Date: Seeing inherited Fields in Eclipse Debug mode
- Next by Date: Re: Great SWT Program
- Previous by thread: Re: Recursion Usage and Concepts - Newbie Question
- Next by thread: Re: jvmTI raw monitor
- Index(es):
Relevant Pages
|