Data Structures & AlgorithmsVery hardTCS Digital · Infosys SP

Only the lower triangle (including the diagonal) of a 10 × 10 matrix is stored COLUMN by column in a 1-D array B starting at B[0] (indices 0-based). At which index of B is element (7, 5) stored?

  1. A. 52
  2. B. 43
  3. C. 42
  4. D. 33

Correct answer: C. 42

Column k of the lower triangle holds n − k elements (rows k..n − 1). Columns 0..4 hold 40 elements; element (7, 5) is 2 further down column 5: index 42.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic