How do you decide when to use HashMap and when to use TreeMap ?5
669 5b5cc7cee4d2b41977751119
Q: How do you decide when to use HashMap and when to use TreeMap ?
- Show Answer
- Workspace
- Discuss
Answer :
Explanation :
For inserting, deleting, and locating elements in a Map, the HashMap offers the best alternative. If, however, you need to traverse the keys in a sorted order, then TreeMap is your better alternative. Depending upon the size of your collection, it may be faster to add elements to a HashMap, then convert the map to a TreeMap for sorted key traversal.
Similar Questions
Since Nithya and Suganya exchange places, so Rita’s new position is the same as Monika’s earlier position. This position is 17th from the right and 10th from the left. Therefore Number of girls in the row = (16 + 1 + 9) = 26.