proper deletion algorithm for Patricia trie
- From: Peter Friend <pafriend@xxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 00:57:17 GMT
I have been working on a Patricia trie implementation for storing counts of version 4 IP addresses. When the count reaches 0, I need to delete the node.
I am using a variant that contains no NULL links. The deletion cases I think I need to handle are:
1. node has left and right pointers that point up to the node itself 2. the left or right pointer points to the node itself 3. the node is internal, and both branches point down the tree
Cases 1 and 2 are straightforward. The third case is trickier, and I have it working *most* of the time, but I am missing something.
Since the tree is being used to store IP addresses, I have a fixed length array for storing the path taken to the matching node. For case 3 I copy the skip value from the matching node to the previous node in the path (which points to the matching node). I then replace the matched node with the node that points to it, and adjust pointers. The pointer adjustments are where I think I am missing a case.
I haven't found a Patricia delete algorithm online, or in my books, though I would expect it to be similar to deletion in a trie without the path compression. Hints or pointers to any relevant papers would be appreciated.
Thanks in advance,
Peter
.
- Follow-Ups:
- Re: proper deletion algorithm for Patricia trie
- From: A.G.McDowell
- Re: proper deletion algorithm for Patricia trie
- Prev by Date: String Coverage Problem
- Next by Date: Re: Efficient way to store an isomorphism?
- Previous by thread: String Coverage Problem
- Next by thread: Re: proper deletion algorithm for Patricia trie
- Index(es):
Relevant Pages
|