You must sum transaction amounts grouped by account (account is a string) from a log with timestamp, account, amount. Which data structure provides the most efficient per-account aggregation?
Choose an answer
Tap an option to check your answer.
Correct answer: A hash table.
Why this is the answer
A hash table (or hash map) is the most efficient choice because it provides average O(1) time complexity for insertions and lookups. You can use the account string as the key and the running sum of amounts as the value. As you process each log entry, you can quickly find the account's current sum and add the new amount. A linked list would require O(n) time to find each account, making aggregation slow. A two-dimensional array would also be inefficient for string-based keys and dynamic sizing. A comma-delimited string is a storage format, not a data structure suitable for efficient in-memory aggregation.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed