Question: Assignment: Create a public static method named rotateArray that takes as input a square ( NxN ) two - dimensional int array and performs a

Assignment: Create a public static method named rotateArray that takes as input a square (NxN) two-dimensional int array and performs a 90-degree clockwise rotation on it. The method should return the new rotated array.
A 90-degree clockwise rotation of an array involves moving the elements such that the element at array[i][j] moves to array[j][N-1-i] where N is the length of each side of the square array;
Assume that the input array will always be square (i.e., the number of rows is equal to the number of columns);
Do not use any additional libraries or data structures.
Suppose the following array is provided as input:
{{1,2,3},
{4,5,6},
{7,8,9}}
then rotateArray(originalArray) should return:
{{7,4,1},
{8,5,2},
{9,6,3}}

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!