(ArrOp Class) Create a class called ArrOp which doesn’t have any instance variables. Your class should have the following methods
a. public int[ ] linearize(int[ ][ ] A) that takes a two-dimensional array as a parameter and returns a one-dimensional array with all the elements of the two-dimensional array.
For example, given the following array:
30 20 10
50 90 60
70 80 40
The method will return a 1-dimensional array with the following elements:
30 20 10 50 90 60 70 80 40
b. public void SortArray(int[ ] A) that takes a one-dimensional array and sort its elements in descending order. For example, given the following array:
30 20 10 50 90 60 70 80 40
The method will sort the array elements to be as following:
90 80 70 60 50 40 30 20 10
c. public void Rotate(int [ ] A) that takes a one-dimensional array and rotate the contents of A one step the right using system method System.arraycopy
For example, given the following array:
90 80 70 60 50 40 30 20 10
The method will rotate the array elements one
Comments
Leave a comment