• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

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

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments