Re: proper deletion algorithm for Patricia trie
- From: Peter Friend <pafriend@xxxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 21:22:57 GMT
On 2005-08-11 22:11:44 -0700, "A.G.McDowell" <mcdowella@xxxxxxxxxxxx> said:
I Have played a bit with Patricia trees: see http://www.mcdowella.demon. co.uk/Patricia.html, which has a link to a zip file of C++ and the following text:
Delete is trickier. If you are lucky, the node you wish to delete will have at most one link to a node other than itself. These cases are easy edits. If your node has two pointers out to nodes other than itself, some node further down the tree must have an up pointer to it. It turns out that if you take this second node and change its bit offset to that of the node to be deleted, you can shove it in where the node to be deleted was with only a few pointer changes, and still have a valid Patricia tree afterwards.
I actually did find your site during my search, which is where I got the idea for copying the bit offset around. The reason deletion was not working properly was rather dumb. The variant I had coded used no NULL links. The result is that eventually you will end up trying to delete a node which has more than one link pointing up the tree to it, which effectively makes deletion impossible to implement in a sane fashion. One I changed my implementation to handle null links, the property of only one up pointing link to each node was restored, and deletion works properly now.
Peter
.
- References:
- Re: proper deletion algorithm for Patricia trie
- From: A.G.McDowell
- Re: proper deletion algorithm for Patricia trie
- Prev by Date: An MSSP-Like Problem
- Next by Date: convex hull and convex functions
- Previous by thread: Re: proper deletion algorithm for Patricia trie
- Next by thread: modified-- strongly connected components(SCC)?
- Index(es):
Relevant Pages
|