Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Refer to the following method rotate that takes a two-dimensional array a and returns a two-dimensional array b made by rotation a by 90 degrees

Refer to the following method rotate that takes a two-dimensional array a and returns a two-dimensional array b made by rotation a by 90 degrees counterclockwise.

If a holds:

1 2 3

4 5 6

b = rotate(a) will hold:

4 1

5 2

6 3

public int[][] rotate(int[][]a){

int rows = a[0].length;

int cols = a.length;

int[][] b = new int [rows][cols];

for (int r=0; r < rows; r++)

for (int c=0; c < cols; c++)

b[r][c] = <MISSING EXPRESSION>;

return b;

}

Which of the following should replace <MISSING EXPRESSION>?

A) a[c][rows - 1 - r]

B) a[cols - 1 - c][rows -1 -r]

C) a[rows - 1 - r][cols - 1- c]

D) a[cols - 1 - c][r]

E) a[c][r]

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions