Re: Specific Cloning Question
- From: "Alex" <alexander.webb@xxxxxxxxx>
- Date: 22 Sep 2006 07:16:04 -0700
Oliver Wong wrote:
"Alex" <alexander.webb@xxxxxxxxx> wrote in message
news:1158920061.757641.292170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3) If I am satisfied with the new tree can I not simple set the old
tree equal to the new tree?
Probably not. You can't "set" an object. You can set the value of a
reference (i.e. to point to the new tree instead of the old tree), but that
will not update all the other references to the old tree.
There are more time-optimal ways of doing this, but without further
information, the best I can come up with is to clone the tree, apply the
operation on the clone, test if it satisfies whatever you want, and if it
does, re-apply the operation on the old tree. Discard the clone in either
cases.
The reason I have not managed to cut down the program is that I am not
sure how to do that without losing the complexity that is causing the
problem. I have made smaller versions of things and tried cloning
things that contain lists of references but I don't seem to get the
problems in these oversimplified examples.
What's this about "lists of references"? This is the first time you
mention it, AFAIK. Previously you said only that the tree has a reference to
its parent, and its children. Being a binary tree, this means exactly 3
references in every node.
Anyway, if your time is too valuable there is no pressure on you or
anyone else to help or to even read this. However, I fail to see that
there is much harm in asking, just in case someone out there knows how
to help and has some time to do it.
Have you considered a recursive solution?
- Oliver
No,
The trees consist of nodes, and each node has a reference to its parent
and children. Each tree is made up of lots of nodes, hence a list of
them.
Sorry if that was unclear.
I am not entirely sure what you mean by a "recursive solution". I have
tried cloning the tree by cloning all the nodes in it. However the
problem here is that when I try to clone Node A it has a reference to
Node B as its parent so Node B gets cloned. But when I am cloning Node
B, it has a reference to Node A as its child it goes back to trying to
clone A again.
Alex
.
- Follow-Ups:
- Re: Specific Cloning Question
- From: Oliver Wong
- Re: Specific Cloning Question
- References:
- Specific Cloning Question
- From: Alex
- Re: Specific Cloning Question
- From: Thomas Weidenfeller
- Re: Specific Cloning Question
- From: Alex
- Re: Specific Cloning Question
- From: Oliver Wong
- Specific Cloning Question
- Prev by Date: Re: Specific Cloning Question
- Next by Date: Re: jawk long string arguments
- Previous by thread: Re: Specific Cloning Question
- Next by thread: Re: Specific Cloning Question
- Index(es):
Relevant Pages
|
|