User interface language: English | Español

Date November 2017 Marks available 1 Reference code 17N.1.HL.TZ0.14
Level HL Paper 1 Time zone no time zone
Command term State Question number 14 Adapted from N/A

Question

Consider the following two-dimensional array, MAT, with dimensions 6 × 6.

The value −1 is stored in MAT at position [4][2]. The position [4][2] means row 4 and column 2.

A two-dimensional array in which most of the elements are zero is called a sparse matrix. A sparse matrix can be compressed by storing only non-zero elements using three one‑dimensional arrays.

The first array, VALUES, stores all non-zero elements taken from the sparse matrix in row‑major order (left-to-right then top-to-bottom order).

The length of the array VALUES is equal to the number of non-zero elements in the sparse matrix. For the sparse matrix above, MAT, the array VALUES is:

The second array is ROWC. ROWC[i] stores the number of non-zero elements, from row 0 to row i of the sparse matrix, inclusive.

The length of ROWC is equal to the number of rows in the sparse matrix. For MAT the array ROWC is:

For example, ROWC[2] stores 3 because in MAT there are three non-zero elements from row 0 to row 2, inclusive.

The third array, COL, stores the column index for each non-zero element in the sparse matrix. COL[i] stores the sparse matrix column index for the non-zero element stored in VALUES[i]. For MAT the array COL is:

Consider the following three arrays. They hold the compressed contents of a 7 × 7 sparse matrix, BIGMAT.

State the total number of elements stored in MAT.

[1]
a.

State the number of non-zero elements in MAT.

[1]
b.

State how many rows in BIGMAT contain only zeros.

[1]
e.

State the index in VALUES of the first non-zero element in row 5 of BIGMAT.

[1]
f.i.

State the index in VALUES of the first non-zero element in row 5 of BIGMAT. 

[1]
f.i.

Markscheme

36;

a.

7;

b.

1;

e.

5;

f.i.

5;

f.i.

Examiners report

[N/A]
a.
[N/A]
b.
[N/A]
e.
[N/A]
f.i.
[N/A]
f.i.

Syllabus sections

Topic 5: Abstract data structures » 5.1 Abstract data structures
Show 80 related questions
Topic 5: Abstract data structures

View options