Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions