Re: Deletion from a red/black tree
- From: Lech Duraj <lduraj@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Jun 2007 01:51:24 +0200
In Introduction to Algorithms by Thomas Cormen insertion and deletion is said to take O (lg n) time.
I have read that delete takes amortized constant time if you supply the pointer to the element being deleted (you can omit the searching) but that is exactly the version described in cormen and it is said to take O(lg n) time, so how does this fit together?
Another thing, delete also use tree-successor which runs in the height of the tree so this would also slow down delete to O(lg n).
Try to use "lazy deletion". Instead of removing a node, just mark it as "deleted" (and of course answer negatively for all queries on this element). When the number of marked nodes exceeds half the size of the tree, rebuild it from scratch, perfectly balanced, without marked nodes - it's easy to do it in linear time. This gives amortized O(1) time for deleting (if the pointer is supplied!), while keeping logarithmic height of the tree.
--
Lech Duraj
.
- Follow-Ups:
- Re: Deletion from a red/black tree
- From: desktop
- Re: Deletion from a red/black tree
- References:
- Deletion from a red/black tree
- From: desktop
- Deletion from a red/black tree
- Prev by Date: Finding longest path between two vertices
- Next by Date: Re: Deletion from a red/black tree
- Previous by thread: Deletion from a red/black tree
- Next by thread: Re: Deletion from a red/black tree
- Index(es):
Relevant Pages
|