GATE | GATE CS 1996 | Question 62
A two dimensional array A[1…n][1…n] of integers is partially sorted if
∀i, j ∈ [1...n−1], A[i][j] < A[i][j+1] and A[i][j] < A[i+1][j]
Fill in the blanks:
a) The smallest item in the array is at A[i][j] where i=………………and j=………………….
b) The smallest item is deleted. Complete the following O(n) procedure to insert item x (which is guaranteed to be smaller than any item in the last row or column) still keeping A partially sorted.
procedure insert (x: integer);
var i,j: integer;
begin
i:=1; j:=1, A[i][j]:=x;
while (x > ...... or x > ......) do
if A[i+1][j] < A[i][j] ......... then begin
A[i][j]:=A[i+1][j]; i:=i+1;
end
else begin
............
end
A[i][j]:= .............
end
.
Answer:
Explanation:
Quiz of this Question
Please comment below if you find anything wrong in the above post
Recommended Posts:
- GATE | GATE CS 1996 | Question 50
- GATE | GATE CS 1996 | Question 73
- GATE | GATE CS 1996 | Question 74
- GATE | GATE CS 1996 | Question 49
- GATE | GATE CS 1996 | Question 39
- GATE | GATE CS 1996 | Question 17
- GATE | GATE CS 1996 | Question 48
- GATE | GATE CS 1996 | Question 75
- GATE | GATE CS 1996 | Question 54
- GATE | GATE CS 1996 | Question 53
- GATE | GATE CS 1996 | Question 52
- GATE | GATE CS 1996 | Question 40
- GATE | GATE CS 1996 | Question 35
- GATE | GATE CS 1996 | Question 51
- GATE | GATE CS 1996 | Question 5



