Re: Urgent Recurrence Problem, Please Help !
- From: muede73 <muede73@xxxxxx>
- Date: Tue, 30 Oct 2007 06:09:21 +0100
Tonny wrote:
There are two integer lists: V(1..N) and W(1..N)
V(i) is positive and W(i) is non-negative for all i. (i.e. W(i) can be
zero)
Now I'm going to select the elements from the V list, the constraint
is : if I pick V(i), then I must avoid taking V(i+1),V(i+2),..., V( i+
W (i) )
The problem is how to maximize the sum of the V's I can select.
Can anyone help me out by using a recursive way? Thanks a lot!!!
Mh , I wonder if this works :
List S(List V,List W)
{
if(empty(V))
return [];
endif
List part = S(rest(V),rest(W));
if ( first(V) > sum(first_n_elems(part,first(W))) )
return cons(first(V),result);
else
return cons(0,result);
endif
}
-ap
.
- References:
- Urgent Recurrence Problem, Please Help !
- From: Tonny
- Urgent Recurrence Problem, Please Help !
- Prev by Date: Re: Recursively enumerable sets
- Next by Date: Re: Urgent Recurrence Problem, Please Help !
- Previous by thread: Re: Urgent Recurrence Problem, Please Help !
- Next by thread: How to abstract a set?
- Index(es):
Relevant Pages
|