Re: Data structure for fast associative array with lookup by both key and index
- From: Gene <gene.ressler@xxxxxxxxx>
- Date: 28 May 2007 19:23:55 -0700
On May 28, 8:04 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:
Gene wrote:
On May 26, 2:17 pm, CBFalconer <cbfalco...@xxxxxxxxx> wrote:
Gene wrote:
On May 26, 5:23 am, "A.J." <naijir...@xxxxxxxxx> wrote:
I'm looking for a data structure for an associative array with the
following properties:
... snip ...
CBFalconer's hashlib is excellent, but I'm guessing from your design
that you need deletions to "collapse" the array index space so there
are no holes. I can't see a way this can be done in O(1). The order
stats tree is a nice O(log n) solution. You pay O(log n) on insert
(with respect to a hash table e.g.) in order to allow deletions to be
O(log n) rather than O(n).
Thanks. However hashlib can do O(1) deletions. The hashwalk
function allows compression to a single list at any time (O(N)).
The result is invalid after further insertion/deletions, but will
survive searches. It also seems to be accurate, in that I have had
no reports of flaws in several years.
Thanks. But I guess I'm not clear on what you're proposing. If you
add A, C, D to initially empty x then x[1]=A, x[2]=C, x[3]=D. Now
delete A. You are saying that moving C and D to positions x[1] and
x[2] will require O(n). Yes? With the order statistics tree, the
deletion remains O(log n). That's what I was getting at.
A hash table is NOT an array. Things don't normally get moved.
Get it and look. It's not that big.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account fromhttp://www.teranews.com- Hide quoted text -
- Show quoted text -
Thanks. I guess I'm not communicating very well. I had looked at your
package long before this conversation. It's nice. I have implemented
similar designs myself.
The OP however is asking for a data structure that can be indexed in
order of insertion _with deletion_. When item K is deleted from an
array of N items, items at index positions K+1 to N must be "moved
down" to fill the hole to maintain the orginal order, and the new
array length is N-1. With a simple array, this is an O(N)
operation.
With an order stats tree index, you don't need O(N). Time O(log N)
per operation is enough to delete from a balanced tree -- a standard
tradeoff. Inserts get more expensive than the array, O(1) to O(log
N), but deletes get cheaper, O(N) to O(log N).
With a hash table mapping indices to values, deleting a hash element
ought to be O(1). It obviously is with yours, since you just mark
items deleted in a closed table. But still leaves the "move down". I
don't see how this can be accomplished with anything less than O(N) --
looking up items K+1 to N, deleting, and reinserting with new keys.
Again, this is the OP's requirement, not mine.
If you have a way, I'm truly interested.
.
- References:
- Data structure for fast associative array with lookup by both key and index
- From: A.J.
- Re: Data structure for fast associative array with lookup by both key and index
- From: Gene
- Re: Data structure for fast associative array with lookup by both key and index
- From: CBFalconer
- Re: Data structure for fast associative array with lookup by both key and index
- From: Gene
- Re: Data structure for fast associative array with lookup by both key and index
- From: CBFalconer
- Data structure for fast associative array with lookup by both key and index
- Prev by Date: Re: Data structure for fast associative array with lookup by both key and index
- Next by Date: Re: Best Programming language for Network programming (serious server application
- Previous by thread: Re: Data structure for fast associative array with lookup by both key and index
- Next by thread: doubt on kruskal algog's complexity
- Index(es):
Relevant Pages
|