Hashmaps vs storing data in the tree

Jump to navigation Jump to search
Revision as of 25 July 2012 at 18:39.
The highlighted comment was created in this revision.

Hashmaps vs storing data in the tree

I was working on my kd-tree and one of the changes I made was to store the data in the tree rather than in a hashmap, thinking that this would save time. However, in my benchmarks, it is much faster to use a hashmap. Does anyone know why this would be the case?

    AW18:17, 25 July 2012

    It's very strange question because hashmap and kd tree is absolutly different structures with different aims and contract and for sure map faster because it's nature. May be you publish source code with usage of map and tree?

      Jdev18:38, 25 July 2012
       

      O, looks like i misunderstand you. Do you mean why HashMap is faster than TreeMap? I'm not sure but i think, that hash map has efficiency O(1) but tree map O(log N) because tree map are sorted and based on red-black tree. I do not describe how they works because my english skill...

        Jdev19:39, 25 July 2012