Question: Int search( int *p, int n, int m, int k, int *r, int *c){ Int i; Int index = -1; For( i = 0; i

 Int search( int *p, int n, int m, int k, int
Int search( int *p, int n, int m, int k, int *r, int *c){
Int i;
Int index = -1;
For( i = 0; i
If ( p[i] ==k) {
*r =
*c =
Index =
}
}
Return
}
1. Complete the implementation of the following C function that searches a 2D array for a key. The parameter p points to a 2D int array of dimensions m by n:int a[m][n]. The parameter k is the key value to search. The pointers r and c will point to the result of a successful search: the row and column indices of the element in the 2D array whose value is equal to the key. The function returns the linear index of the found element if the search is successful. It returns -1 if the key is not found in the array. Do not create additional variables and do not remove any existing code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!