GATE / CS ARCHIVE

GATE CSE 1996 / QUESTION 14(a)

Locate a sorted-array minimum

Data Structures · Arrays & Linked Lists · Full GATE CSE 1996 paper

GATE 1996, Q14(a) Descriptive
Report issue

Arrays & Linked Lists

Question 14(a), GATE 1996: An n×n integer array is intended to increase along every row and every column. Where is its minimum? The reproduction quantifies both inequalities only for i,j∈[1,n−1], which is narrower than full row/column sorting.
Question 14(a), GATE 1996: An n×n integer array is intended to increase along every row and every column. Where is its minimum? The reproduction quantifies both inequalities only for i,j∈[1,n−1], which is narrower than full row/column sorting.
Tap to enlarge
Answer & solution

Answer: Under the intended full row/column order: i=j=1. Under the literal restricted quantifier: not guaranteed. (no official key was published)

Under the standard partially sorted matrix interpretation, A[1,1]≤A[i,j] for every cell: move downward from (1,1) to (i,1), then rightward to (i,j), using monotonicity at each step. With strict comparisons and n>1 this makes A[1,1] the unique minimum; the requested blanks are i=1 and j=1. For n=1 the only cell is trivially the minimum.

There is a literal specification issue. The paper attach i,j∈[1,n−1] to both comparisons A[i,j]<A[i,j+1] and A[i,j]<A[i+1,j]. This does not constrain the last row horizontally or the last column vertically. In particular, A[n,n] appears in neither type of comparison. For n=2, the matrix [[1,2],[3,−100]] satisfies the printed comparisons 1<2 and 1<3, yet its minimum is at (2,2).

The usual intended definition instead quantifies horizontal comparisons for 1≤i≤n,1≤j<n, and vertical comparisons for 1≤i<n,1≤j≤n. The answer (1,1) follows from that corrected definition, not from the restricted literal one. This caveat also applies to the insertion procedure in the next subpart.

Original paper, page 8