Design Data Structure for Sparse Matrices Operations
PinterestData Scientist · OnsiteLast updated
This question evaluates a candidate's ability to design efficient data structures and implement algorithms for sparse matrix storage and operations, emphasizing space-efficient representations, matrix arithmetic, and computational complexity reasoning.
Scenario
Analytics engine stores extremely sparse numeric matrices.
Question
Design a data structure to store two sparse matrices and implement print(), add(A,B) and multiply(A,B). Discuss complexity for each operation.
Hints
Use dictionary-of-keys or CSR; pre-index rows and columns to speed multiplication.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.