Answered! Please help me write a psuedocode for the following question… Write a module that searches a 2D array for a target….

Please help me write a psuedocode for the following question…

Write a module that searches a 2D array for a target. The function, if successful, returns true and the target’s row and column in the array. If unsuccessful, the module returns false and a pair of zeroes

{boolean, integer, integer} search2D(array, target)

end search2D

Expert Answer

 {boolean, integer, integer} search2D(array, target):

   status = false

// Loop to traverse through the rows
for i->1 to array.length :

// loop to traverse through the columns in the row
for j->1 to array[i].length :

// Now i,j point to the location of element
// if element is same as target, return true
if(array[i][j] == target):
status = true
return(status, i, j)
end if;
end for;
end for;

// If no match found, return false
return (status, 0, 0)

Still stressed from student homework?
Get quality assistance from academic writers!