Data Structures19 sections · 729 units
Open in CourseQuiz: Frequency Counting
Time complexity
Check Your Understanding
To count frequency of each element in an array of n elements, what is the time complexity using a hash map?
- A.O(n²) - need to compare each pair
- B.O(n log n) - need to sort first
- C.O(n) - one pass through the array
- D.O(1) - constant time