Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU OR GIVE OU A DISLIKE [Q-2] $$ begin{array) (1) text (Problem Description: Saddle point of
PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU OR GIVE OU A DISLIKE
[Q-2] $$ \begin{array) (1) \text (Problem Description: Saddle point of a matrix W \text (Input: an integer matrix and two nonnegative integer numbers ! \mathrm{n} \text { and ) \mathrm{m} \text { representing the \text { numbers of rows and columns of the matrix, respectively (no restriction on } \mathrm{n} \text { and } \mathrm{m} \text(). The input) Problem Description: Saddle point of a matrix Input: an integer matrix and two nonnegative integer numbers n and m representing the numbers of rows and columns of the matrix, respectively (no restriction on n and m). The input has the following format: + line 1 contains n and m, separated by a white space + n following lines, each line has m numbers, separated by a comma + note that the last line does not contain 'n' Output: the saddle point value of the matrix, if it has, otherwise output an empty string For an nxm matrix M, the value at cell (1 ]) is a saddle point of the matrix if M[i][] is simultaneously the minimum value of the i_th row and the maximum value of the j_th column. Note that a matrix can have zero or multiple saddle points. But, if it has multiple saddle points, they are all equal. Requirement: You cannot use any array variable. To represent an array you must use a pointer variable. Hint: You should compute the min of each row and max of each column. Save them somewhere. Then look at each cell (1, 1) and check if it equals the min of row i and max of column]. Examples: Input1 33 1,2,3 4,5,6 7,8,9 Output 1 7 Input2 33-2,15,-2-5, -7,-4-6,20,-8 Output2 -2 Input3 3 3 8,1,9 7,2,6 3,4,5 Output3 input4 00 Output4 Inputs 34 -1,-2,- 1,3,-1-3,-5,-2,3,-5 0,0,0,1 Outputs: 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started