Campbell Ritchie wrote:Stop worrying about the internals of classes. You don't need to know it.
Well, you can download the source code and look at the rehashing algorithm, but you won't want to do your own rehashing.A few minutes ago, I wrote: . . . You cannot predict which “bucket” a particular K goes into because of the rehashing.
Campbell Ritchie wrote:Right. Stop writing hashcodes in decimal. Write them in hexadecimal.
Campbell Ritchie wrote: If you have a 16‑element array, the result of that little formula is the same as the rightmost hex digit in the hashcode, after rehashing. You can see that easily if you write in hexadecimal.
Also, you not will reach the default load factor after 9 entries. The default size for a hash map is 16 and the default load factor is 75%, so using (13, 0.75f) will give you exactly the same as the default, and you reach the load factor at 12 entries
Simon Roberts wrote:I think your question is misplaced (i.e. in the wrong forum.) This is, I believe, a question about (a college classwork assignment on the topic of) "Algorithms". That's not the same as "using the Java class called HashMap", and for sure not "Beginning Java" in any case
Meanwhile, I find the question intriguing and worthwhile, and realize I need to brush up on some long forgotten stuff that, as other commentators have observed, regular day to day programmers tend not to worry about!
Campbell Ritchie wrote:I looked up quadratic probing and found this.
mark cortez wrote:
With the Quadratic probing I did not know whether or not each collision starts with k+1 or is the quadratic cumulative?
For example:
item one is in index 3
item two is in index 3 therefore it goes in k+1 (3+1) or index 4
If item three goes in index 4 do you compute its new location with k+1 again or k+2 squared.
When I did my problem I started at k+1 for each new collision.
I think you are right. Algorithms probably belong in the “General Computing” forum, so let's try there.Simon Roberts wrote:I think your question is . . . in the wrong forum. . . .
Straws are for suckers. Now suck on this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|