Program to find the saddle point coordinates in a given matrix | Faceprep

Program to find the saddle point coordinates in a given matrix | Faceprep

The program to find the saddle point coordinates in a given matrix is discussed here. A saddle point is an element of the matrix, which is the minimum element in its row and the maximum in its column.

program to find the saddle point coordinates in a given matrix


For example, consider the matrix given below

1 2 3

Mat[3][3] = 4 5 6

7 8 9

Here, 7 is the saddle point because it is the minimum element in its row and the maximum element in its column.


Program to find the saddle point coordinates in a given matrix

Click here to learn more about FACE Prep PRO


program to find the saddle point coordinates in a matrix

Algorithm to find the saddle point coordinates in a given matrix

  1. Input the matrix from the user.
  2. Use two loops, one for traversing the row and the other for traversing the column.
  3. If the current element is the minimum element in its row and the maximum element in its column, then return its coordinates.
  4. Else, continue traversing.

The program to find the saddle point coordinates in a given matrix is given below.

@@coding::1@@

Time complexity: O(n^2)


Program to find the saddle point coordinates in a given matrix

Click here to learn more about FACE Prep PRO


Recommended Programs


program to find the saddle point coordinates in a matrix

c