| 1. |
Which Data Structure Is Used To Implement Hashmap In Java? |
|
Answer» Even though HASHMAP represents a hash table, it is internally implemented by using an ARRAY and linked list data structure in JDK. The array is used as bucket while a linked list is used to store all mappings which land in the same bucket. From JAVA 8 onwards, the linked list is dynamically replaced by binary search tree, once a number of elements in the linked list cross a certain threshold to IMPROVE PERFORMANCE. Even though HashMap represents a hash table, it is internally implemented by using an array and linked list data structure in JDK. The array is used as bucket while a linked list is used to store all mappings which land in the same bucket. From Java 8 onwards, the linked list is dynamically replaced by binary search tree, once a number of elements in the linked list cross a certain threshold to improve performance. |
|