GATE Computer ScienceHardGATE CS

An m × n sparse matrix with m = 1000 rows is stored in coordinate form (three arrays row, col, val, each of length nnz) or in compressed sparse row form (arrays col and val of length nnz and a row-pointer array of length m + 1). Each array element takes one word. For what smallest number of non-zeros nnz does CSR use strictly fewer words than coordinate form?

  1. A. 1002
  2. B. 3001
  3. C. 1000
  4. D. 1001

Correct answer: A. 1002

Coordinate form needs 3·nnz words and CSR needs 2·nnz + 1001. CSR is strictly smaller when 3·nnz > 2·nnz + 1001, i.e. nnz > 1001, so the smallest integer is 1002 (at 1001 they tie).

More Programming and Data Structures (GATE) questions

Exams that ask this topic