What is the space used by programs when we use Hashmap in our program?
2017
What is the space used by programs when we use Hashmap in our program?
- A.
O(1)
- B.
O(LogN)
- C.
O(N)
- D.
None
Attempted by 485 students.
Show answer & explanation
Correct answer: C
The space complexity of a HashMap is O(N) because it stores N key-value pairs. Each entry requires constant space, leading to linear total memory usage relative to the number of elements.