nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #71

You are parsing a log file that contains three columns: a timestamp, an account number (a string), and a transaction amount (a number). You want to calculate the sum of all transaction amounts for…

The correct answer is B. A hash table. A hash table (also called a dictionary or map) is the optimal data structure for this problem. You use each unique account number as a key and accumulate the transaction total as the value. Lookups and inserts are O(1) on average, so processing the entire log file is O(n). A…

Designing and implementing efficient data processing solutions

Question

You are parsing a log file that contains three columns: a timestamp, an account number (a string), and a transaction amount (a number). You want to calculate the sum of all transaction amounts for each unique account number efficiently. Which data structure should you use?

Options

  • AA linked list
  • BA hash table
  • CA two-dimensional array
  • DA comma-delimited string

How the community answered

(60 responses)
  • A
    5% (3)
  • B
    90% (54)
  • C
    3% (2)
  • D
    2% (1)

Explanation

A hash table (also called a dictionary or map) is the optimal data structure for this problem. You use each unique account number as a key and accumulate the transaction total as the value. Lookups and inserts are O(1) on average, so processing the entire log file is O(n). A linked list (A) requires O(n) traversal per lookup, making aggregation O(n²). A two-dimensional array (C) requires knowing all account numbers in advance and doesn't support efficient key-based lookup. A comma-delimited string (D) has no indexing capability at all.

Topics

#Data Structures#Hash Tables#Algorithm Efficiency#Data Aggregation

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice