The hashmap of Java is implemented using hash tables, we note that the parameters that affect performance: initial capacity and load factor. http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html The associative array of C + + (map) is implemented using red-black tree ( balanced binary tree). The complexity of insertion and removal is logarithmic. http://www.cplusplus.com/reference/stl/map/ The hashmap will be included in next version of C + + http://en.wikipedia.org/wiki/Hash_map_% 28C% 2B% 2B% 29
Wladimir Araujo Tavares *Federal University of CearĂ¡ * On Sun, Apr 3, 2011 at 1:24 PM, rAun007 <raunak.ra...@gmail.com> wrote: > Hi Vaibhav, > > I perfectly understood your point but my question is: > > Which data structure will you use to implement the HashMap if you have > to implement ur own HashMap. > > > > On Apr 3, 7:46 pm, vaibhav agrawal <agrvaib...@gmail.com> wrote: > > For implementing a HashMap, I believe following things need to be > > determined: > > > > 1. Good Hashing Function > > 2. Allocation of an array of pointers containing the structure of the key > > and values to be stored. The size of array could be determined, based on > the > > number of key/value pairs to be stored, and how much memory is available > or > > how fast we want the HashMap to work. > > > > Working: > > 1. Storage: > > Any key/value pair need to be stored, the key would be passed to the hash > > function to get the index of the array where the key/value pair need to > be > > stored. If already a key/value is stored there, then a chain would be > > created. > > > > 2. Look-up: > > Any key which need to be looked upon, the key would be passed to the hash > > function to get the index of the array where the key/value pair is > stored. > > The chain stored at that index, would be then looked sequentially to find > > out the value. If none of the node contains the key, then key is not > present > > in HashMap. > > > > Thanks, > > Vaibhav > > > > > > > > > > > > > > > > On Sun, Apr 3, 2011 at 6:52 PM, rAun007 <raunak.ra...@gmail.com> wrote: > > > Hi Geeks, > > > > > I was trying to find a good approach to implement a Hash Map of your > > > own but got confused by searching the answer on the net. > > > > > It would be very much appreciated if we can discuss different > > > approaches and the best way to implement the same. > > > > > Regards, > > > > > Raunak > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to algogeeks@googlegroups.com. > > > To unsubscribe from this group, send email to > > > algogeeks+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.