algorithm - Run time to insert n elements into an empty hash table -
People say that O (1) is taken to insert the hash table, so put n element (O) N) should be. This is not true for big n, however, since one responder said, "You need to satisfy the expected Amortized O (1) extension of the table and at any time of confrontation with a new random hash function Make everything new. "
So: What is the average running time of inserting N elements in a hash table? I know that this is probably implementation-dependent, so mention what type of implementation you are talking about. For example, if (log n) are equally distance collisions, and to solve every collision o (k), where is the current size of k hashtable, then you want this repetition relation:
T (n) = t (n / 2) + n / 2 + n / 2 (i.e., time for inserting N / 2 elements If you take, then you have a collision, it takes n / 2 to solve it, then you merge without a N / 2 one collision). It is still o (n), so yay. But is it fair?
It is entirely dependent on how your reshash is disabled, especially if You can guess the expected size of your hashtab a second time, so your runtime has still come to O (n). Effectively, you have to specify how calculation of your resize size is disabled before determining the expected sequence.
Comments
Post a Comment