Now we will broadly discuss the Algorithm and C-code.
What is Saddle Point of a Matrix?
Saddle Point in a Matrix is the point which has the highest value in the respective row and lowest value in the respective column or vice-versa( i.e Lowest in a row and highest in a column).
The code here first takes the Matrix as input.Then shows the matrix to the user.
Then it evaluates the saddle points.
Evaluation:
First we evaluate the maximum and minimum of a row. If they are not equal that means they may be a candidate for a saddle point. But if they are equal that means all the elements in that row are equal. So we don’t consider them as a candidate for a saddle point. “eq” variable is used in this case for checking equality.
Let’s say they are not equal. Then we take maximum of each column and checks with the Minimum element of the row that was evaluated above.If they are the same, then that is shown as a saddle point.
Same case is taken for Maximum in a row and minimum in a column.
“cnt” variable is used to count the number of saddle points in the matrix.If the variable is 0 then there are no saddle points.
Function Definition:
rw(r,dec)
Here “r” stands for corresponding row. The “dec” variable is used to indicate if we are evaluating maximum or minimum. If dec=0,then we are claiming for minimum and if dec=1, then we are claiming for maximum.
col(r,dec)
Here “r” stands for corresponding column.The “dec” variable is used just as rw(r,dec) function.
Further Clarification:
For further detailing,please let me know through your comments.
The actual Code is here.Click here.
0 Responses to Saddle Point Algorithm Clarification