Re: dynamic programming on a tree
- From: "Paul E. Black" <p.black@xxxxxxx>
- Date: Mon, 30 Jan 2006 14:38:11 -0500
On Sun, 29 Jan 2006 11:39:34 -0800, tenida@xxxxxxxxx wrote:
> I have a binary tree. ...
> Each leaf L also has a number associated with it, A(L). In addition user
> inputs an interval [a,b].
>
> Now, I have to assign weights w_i (positive reals) to all nodes
> including leafs such that product of weights from root to a leaf j equals
> A(j).
>
> But, I want to assign weights such that the total number of weights
> that are outside a specified interval [a,b] is minimized. ...
You might try memoizing the number of allowed out-of-interval (OOI)
weights for each node, and the interval of weights that would achieve it.
If the allowed interval is [2,5] and your tree is
root
/ \
20 40
at the node marked 20, for 0 (zero) OOI weights the root could be in the
interval [4,10] (with 4 the weight could be 5 and with 10 the weight
could be 2). At the node marked 40, for 0 OOI weights the root could be
in the interval [8,20]. At the root 0 OOI weights can be satisfied with
anything in [8,10].
Start with 0 (zero) OOI weights at the root. Recrusively propagate the
number of allowed OOI weights down, and the satisfying weight internals
up. If there is no solution at a node, pass back "failure" and the
caller must increase the OOI weight allowance. If at the root, increment
the OOI weights allowance.
-paul-
--
Paul E. Black (p.black@xxxxxxx)
.
- References:
- dynamic programming on a tree
- From: tenida@xxxxxxxxx
- dynamic programming on a tree
- Prev by Date: Re: Graph Theory question
- Next by Date: Re: Significance of "Relativizations of the P =? NP Question"
- Previous by thread: dynamic programming on a tree
- Next by thread: Math Books For Sale
- Index(es):
Relevant Pages
|