Combinatorics & Counting
![Question 1.2, GATE 2000: For 1≤i,j≤n, define v[i,j]=i−j. Find the sum of all n² entries. Options include 0,n−1,n²−3n+2,n²(n+1)/2.](../../assets/questions/CS-2000-Q2-1.webp)
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: Pair entry(i,j) with entry(j,i). Their values i−j and j−i add to zero; diagonal entries are themselves zero.
Step 2: Equivalently, the double sum is n·sum_i i−n·sum_j j, whose terms cancel exactly.
Thus the total is zero for every positive n, option A. Counting only the positive triangular half would omit the equal negative half.