ProgrammingVery hard
For an int matrix a with R rows and C columns stored in row-major order, what is the flat index of the cell at (r, c) in terms of R?
- A. The index is r * C + c, and R does not enter the formula
- B. r * R + c
- C. r + c * R
- D. c * C + r
Correct answer: A. The index is r * C + c, and R does not enter the formula
The number of rows does not change where a row starts. Row r starts after r rows of C elements each.
More C Programming questions
- A matrix of 10 x 10 is searched linearly for a value. About how many cell reads happen in the worst case?
- A 2D array is passed to a function that needs the number of rows. Which argument can it NOT rely on?
- int a[3][3] = {0}; int p = a[1]; p[2] = 7; printf("%d", a[1][2]); What is printed?
- The number of ways to choose a 2 x 2 submatrix in a 4 x 4 matrix (choosing consecutive rows and columns) is what?
- Which of these statements about in-place transposition is correct?
- A table of size 5 uses h(k) = k % 5 with linear probing. Keys 15, 5, 10 and 3 are inserted in that order. How many slots are examined when…