Intermediate Java
Q48 / 100

What is the difference between HashMap and TreeMap?

Correct! Well done.

Incorrect.

The correct answer is B) HashMap is unordered O(1) operations; TreeMap maintains sorted key order with O(log n) operations

B

Correct Answer

HashMap is unordered O(1) operations; TreeMap maintains sorted key order with O(log n) operations

Explanation

HashMap uses hashing for O(1) average performance but no order. TreeMap uses a Red-Black Tree, keeping keys sorted but at O(log n) cost.

Progress
48/100