> not matter how many nodes are affected - result in a completely new copy of the tree.

That is not the case - there is typically structure sharing. If you're replacing a node, then it will share the existing left and right sub-trees. So if you're replacing the root node, then the whole rest of the tree is simply linked to. If you're replacing a leaf node, then as you bubble-up, you'll be sharing parts of the existing tree.

By on 5/14/2011 1:56 PM ()

thank you for your answer!

> there is typically structure sharing. If you're replacing a node, then it will share the existing left and right sub-trees.

how do I achieve this? How would I e.g. implement an "add" (member-) method to the tree type I defined that does not return a new tree but changes the existing one instead?

By on 5/16/2011 2:39 AM ()

Try googleing "F# binary tree".

Here's the top one:

Purely Functional Data Structures: An F# Binary Tree

By on 5/20/2011 10:00 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper