Question
using java plese Question 2 is divided into 2 sections: 2.1, 2.2 When working with matrices that contain a lot of zeros, a more efficient
using java plese
Question 2 is divided into 2 sections: 2.1, 2.2 When working with matrices that contain a lot of zeros, a more efficient representation is needed in terms of space: instead of maintaining a two-dimensional array with all the information, it is enough to maintain a one-dimensional array that keeps only the different organs 0. In this question you will implement a method that converts a two-dimensional array of numbers into a one-dimensional array of objects.
Points) Write a class named Q2 that contains the following method: public static Element [] toArray (double [] [] mat) The method receives a mat parameter that is a two-dimensional array of real numbers and returns an array of objects, for the non-0 members in the mat table. The length of the returned array, will be exactly the number of non-0 members in the mat. It can be assumed that at is not null h and that all rows are not null It can be assumed that all rows contain the same number of columns. For example, if mat is the table:
Then the method will return an array with three objects of type Element: in the first place will appear the limb representing the cell containing 6, in the second place will appear the limb representing the cell containing 9 and in the third place will appear the limb representing the cell containing 3. Note: The Element type is your solution to Section 2.1
6 9 0 0 3 0 6 9 0 0 3 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started