tag:blogger.com,1999:blog-4949964667779944881.post1398229833719760474..comments2024-03-28T22:45:54.284-07:00Comments on One Fork: Hashmap 101: Build your own!Rodhttp://www.blogger.com/profile/01080301889766047685noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-4949964667779944881.post-69748010507359625272015-02-26T00:03:40.799-08:002015-02-26T00:03:40.799-08:00DETAILED EXPLANATION of how HASHMAP works internal...DETAILED EXPLANATION of how HASHMAP works internally in java , with diagrams.<br />http://www.javamadesoeasy.com/2015/02/hashmap-custom-implementation.htmlA Mhttps://www.blogger.com/profile/05041995836375853595noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-85003813431119309692015-02-26T00:03:09.167-08:002015-02-26T00:03:09.167-08:00DETAILED EXPLANATION of how HASHMAP works internal...DETAILED EXPLANATION of how HASHMAP works internally in java , with diagrams.<br />http://www.javamadesoeasy.com/2015/02/hashmap-custom-implementation.htmlA Mhttps://www.blogger.com/profile/05041995836375853595noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-7303824573266224092014-10-31T20:19:31.613-07:002014-10-31T20:19:31.613-07:00How about using key.hashCode() & (buckets.leng...How about using key.hashCode() & (buckets.length -1) ??HARRYhttps://www.blogger.com/profile/17935027855367431878noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-26816806305190768362013-02-27T22:54:21.828-08:002013-02-27T22:54:21.828-08:00excellent code...had i read this article before my...excellent code...had i read this article before my interview i would have got the internshipJaskaran Singh Khalsahttps://www.blogger.com/profile/01068087291494521819noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-43013290446648705432013-01-25T16:02:02.324-08:002013-01-25T16:02:02.324-08:00very clean any easy to understand the basics of ho...very clean any easy to understand the basics of how hash map works. I had spent a lot of time on the source code of HashMap.Javedhttps://www.blogger.com/profile/05541531444008926157noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-83123565274932399372012-12-05T03:15:05.763-08:002012-12-05T03:15:05.763-08:00nice code!
And what are dumb racist kids doing in ...nice code!<br />And what are dumb racist kids doing in a such a technical blog! I thought they were dead already!Gopalhttps://www.blogger.com/profile/11054295719689916228noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-73506596995523144272012-03-21T22:03:52.909-07:002012-03-21T22:03:52.909-07:00@penn73er, he might be british, but you are a raci...@penn73er, he might be british, but you are a racist for sure!Shashank Jainhttps://www.blogger.com/profile/00906870850377698988noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-48038987046872051862012-03-15T12:58:47.126-07:002012-03-15T12:58:47.126-07:00I like the article, but it would be nice if the co...I like the article, but it would be nice if the code would compile. My guess is you're British, a race that is fond of omitting details that in their informed opinion are unimportant.penn73erhttps://www.blogger.com/profile/02017081315318705754noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-25078013927116168562011-09-28T18:03:53.100-07:002011-09-28T18:03:53.100-07:00Why didnt you use Linked List for implementing a b...Why didnt you use Linked List for implementing a bucket. You are traversing it sequentially so not taking any advantage of array. By taking Linked List your problem of increasing bucket size would be solvedthoughts_anshulhttps://www.blogger.com/profile/05745929714698856046noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-16898621943014606702011-06-30T10:05:21.837-07:002011-06-30T10:05:21.837-07:00Nice ArticleNice ArticleAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-3028546497473448722011-02-08T09:40:08.543-08:002011-02-08T09:40:08.543-08:00Changing the number of buckets is costly and requi...Changing the number of buckets is costly and require that the keys are evently split accross the hashcode values interval.<br /><br />Imagine that you are in java. hash code range is something like from -2^31 to 2^31.<br /><br />Let say you want to store numbers from 1 to 1000 in the map as a key. And that you use a naive hashCode algorithm : just the number itself.<br /><br />This is exactly what the JDK 1.5.0_18 does at least.<br /><br />Then you need something like 4 billions buckets to ensure that each number can be accessed instantly.<br /><br />This is really, really bad.<br /><br />Instead what you need is a tree. Each bucket can contain a list of leafs or a sub array of buckets.<br /><br />Your heuristic is now to decide when you switch from a list of leafs to a full array of subbucket.<br /><br />Go back to the numbers from 1 to 1000 exemple. Let say we start with 16 buckets per tree lvl.<br /><br />You will need 8 lvl for your tree to ensure that there is one bucket for each number from 1 to 1000. And you need something like 1200 bucket total. Not so bad...Foudreshttps://www.blogger.com/profile/05977228915328575616noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-85437444210813224772011-02-08T04:49:13.576-08:002011-02-08T04:49:13.576-08:00Hi,
you made this question How HashMap works in J...Hi,<br />you made this question <a href="http://javarevisited.blogspot.com/2011/02/how-hashmap-works-in-java.html" rel="nofollow">How HashMap works in Java</a> even more difficult by asking interviewee to write your own HashMap :) , Nice article though. by the way some important thing to note here is how interviewee reacts to this question not only on coding perspective but also on design and considering performance and usability aspect e.g. how often rehashing should be done, way to provide load factor and collision resolution handling etc. <br /><br />Thanks<br />Javin<br /><a href="http://javarevisited.blogspot.com/2010/10/why-string-is-immutable-in-java.html" rel="nofollow">Why String is immutable in Java </a>Anonymousnoreply@blogger.com