An n × n array v is defined as follows: v[i, j] = i − j for all i, j, 1 <= i…
2000
An n × n array v is defined as follows:
v[i, j] = i − j for all i, j, 1 <= i <= n, 1 <= j <= n
The sum of the elements of the array v is
- A.
0
- B.
n−1
- C.
n² − 3n + 2
- D.
n²(n+1)/2
Attempted by 212 students.
Show answer & explanation
Correct answer: A
The sum of the array elements can be calculated by splitting the double summation into two parts. Since the term i appears n times and j appears n times symmetrically, they cancel each other out completely. Therefore, the total sum of all elements in the n × n array is exactly zero.
A video solution is available for this question — log in and enroll to watch it.