Hello! > Not true. The rehashing is O(n) and it has to be performed O(log n) > times during insertion. Therefore, insertion is O(log n). Rehashing is O(n), but the "n" is the _current_ number of items, not the maximum one after all the insertions. Let's assume you start with a single-entry hash table. You rehash for the first time after inserting the first item (giving hash table of size 2), then after the second item (=> size 4), then after the fourth item (=> size 8) and so on. I.e., when you insert n items, the total cost of rehashing summed over all the insertions is at most 1 + 2 + 4 + 8 + 16 + ... + 2^k (where k=floor(log2(n))) <= 2^k+1 = O(n). That is O(1) operations per item inserted. Have a nice fortnight -- Martin `MJ' Mares <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> http://atrey.karlin.mff.cuni.cz/~mj/ MIPS: Meaningless Indicator of Processor Speed. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Re: [rfc] Near-constant time directo... Chris Mason
- Re: [rfc] Near-constant time directo... Daniel Phillips
- RE: [rfc] Near-constant time directory index for Ext2 Davide Libenzi
- Re: [rfc] Near-constant time directory index for Ext2 Martin Mares
- Re: [rfc] Near-constant time directory index for ... Davide Libenzi
- Re: [rfc] Near-constant time directory index ... Martin Mares
- Re: [rfc] Near-constant time directory in... Davide Libenzi
- Re: [rfc] Near-constant time directo... Martin Mares
- Re: [rfc] Near-constant time dir... Davide Libenzi
- Re: [rfc] Near-constant time directory in... H. Peter Anvin
- Re: [rfc] Near-constant time directo... Martin Mares
- Re: [rfc] Near-constant time dir... H. Peter Anvin
- Re: [rfc] Near-constant time dir... Martin Mares
- Re: [rfc] Near-constant time dir... H. Peter Anvin
- Re: [rfc] Near-constant time dir... Martin Mares
- Re: [rfc] Near-constant time dir... H. Peter Anvin
- Re: [rfc] Near-constant time dir... H. Peter Anvin
- Re: [rfc] Near-constant time dir... Daniel Phillips
- Re: [rfc] Near-constant time dir... H. Peter Anvin
- Re: [rfc] Near-constant time dir... Andreas Dilger
- Re: [rfc] Near-constant time dir... H. Peter Anvin