Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The method changeNegs below should replace every occurrence of a negative integer in its matrix parameter with 0 . / * * Oparam mat the

The method changeNegs below should replace every occurrence of a negative integer in its matrix parameter with 0.
/** Oparam mat the matrix
Precondition: mat is initialized with integers.
Postcondition: All negative values in mat replaced with 0.
code */
}
Which is correct replacement for ??** code **??
I for (int r=0;r mat.length; r++)
for (int c=0; c mat r. length; c++)
if (mat [r][c]0)
mat[r][c]=0;
II for (int c=0;c mat [0].length; c++)
for (int r=0;r mat.length; r++)
if (mat [r][c]0)
mat[r][c]=0;
III for (int [] row : mat)
for (int element : row)
if (element 0)
element =0;
(A) I only
(B) II only
(C) III only
(D) I and II only
(E) I, II, and III
image text in transcribed

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

Recommended Textbook for

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions