Which is better hashset or treeset?



Which is better hashset or treeset?..

Answer / Praveen Krishna Tiwari

Both HashSet and TreeSet are useful in different situations. HashSet provides faster access due to its use of a hash table, but lacks the ability to sort elements. TreeSet offers sorted elements with insertion order maintained, but it has slower performance compared to HashSet.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is the difference between hashmap and arraylist?

1 Answers  


What is difference between an Array and ArrayList?

1 Answers   UGC Corporation,


Define separate chaining?

1 Answers  


What is sequential search? What is the average number of comparisons in a sequential search?

1 Answers  


Discuss the difference between a stack and an Array?

1 Answers  


Explain the terms base case, recursive case, binding time, run-time stack and tail recursion.

1 Answers  


Define a queue?

1 Answers  


What are the difference between malloc() and calloc()?

1 Answers  


Name few classes that implement collection interface?

1 Answers  


How to get top two numbers from an array?

1 Answers  


Why do we use a multidimensional array in data structure?

1 Answers  


What does the dummy header in the linked list contain?

1 Answers  


Categories