(Largest block) Given a square matrix with the elements 0 or l, write a
Your program should implement and use the following method to find the maximum square submatrix:
public static int[] findLargestBlock(int[] [] m)
The return value is an array that consists of three values. The first two values are the row and column indices for the first element in the submatrix, and the third value is the number of the rows in the submatrix.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Modern Database Management
Problem Solving with C++ (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- (Data Structures and Algo C++ Weiss 4th ed - ch7.40): The following divide-and-conquer algorithm is proposed for finding the simultaneous maximum and minimum: If there is one item, it is the maximum and minimum, and if there are two items, then compare them, and in one comparison you can find the maximum and minimum. Otherwise, split the input into two halves, divided as evenly as possibly (if N is odd, one of the two halves will have one more element than the other). Recursively find the maximum and minimum of each half, and then in two additional comparisons produce the maximum and minimum for the entire problem. In C++, find a function which will take in a vector and solve the problem, producing a vector of two elements, the min and max.arrow_forward(Average the major diagonal in a matrix) Write a method that averages all the numbers in the major diagonal in an n * n matrix of double values using the following header: public static double averageMajorDiagonal(double[][] m) Write a test program that reads a 4-by-4 matrix and displays the average of all its elements on the major diagonal. Here is a sample run: 1 2 3 4.0 5 6.5 7 8 9 10 11 12 13 14 15 16 Average of the elements in the major diagonal is 8.625arrow_forward(Sum elements row by row) write a method that returns the sum of all the elements in a specified row in a matrix using the following header: public static double sumRow(double [][] m, int rowIndex) Write a test program that reads a 3-by-4 matrix and displays the sum of each row here is a sample run.arrow_forward
- (GREATEST COMMON DIVISOR) The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write and test a recursive function gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd (x, y) is x; otherwise, gcd (x, y) is gcd (y, x % y), where % is the remainder operator.arrow_forward(PYTHON) (Display matrix of 0s and 1s) Write a function that displays an n-by-n matrix using the following header: def printMatrix(n): Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix. Here is a sample run:arrow_forwardWrite a menu driven C++ program that should perform following operation on matrices using 2D arrays. (Use OOP) The program will first take inputs for both matrices from the user then perform following operations on them: 1.CheckTranspose() This method will ask from user which matrix you want to take transpose and then display its transpose. 2.CheckSymmetric() This method will check symmetric matrix 3.CheckIdentity() This method will check if the matrix is identity 4. Multiplication() This method will multiply two matrices but first check number of rows and columns of corresponding matrices and display "Not possible" in case of inequality in rows and columns. Dont use pointers please use counters only.. Thank you very much.arrow_forward
- Write a menu driven C++ program that should perform following operation on matrices using 2D arrays. (Use OOP) The program will first take inputs for both matrices from the user then perform following operations on them: MultiplyScalar() This method will multiply scalar to a matrix by asking user in which matrix to multiply. DivideScalar() This method will divide a scalar from a matrix by asking user in which matrix to divide. CheckEquality() This method will check the equality of two matrices. CheckSkew() This method will check if a matrix is skew symmetric by taking its transpose first and then if AT = -A Dont use pointers please use counters only.. Thank you very much.arrow_forward(Perfect Numbers) An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6=1+2+3. Write a functionisPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.arrow_forward(Algebra: multiply two matrices) Write a method to multiply two matrices. The header of the method is: public static double[][] multiplyMatrix(double[][] a, double[][] b) To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 × b1j + ai2 × b2j + g + ain × bnj. For example, for two 3 × 3 matrices a and b, c is a11 a12 a13 a21 a22 a23 a31 a32 a33 where cij = ai1 * b1j + ai2 * b2j + ai3 * b3j . Write a test program that prompts the user to enter two 3 * 3 matrices and displays their product.arrow_forward
- (Algebra: multiply two matrices) Write a method to multiply two matrices. The header of the method is: public static double[][] multiplyMatrix(double[][] a, double[][] b) To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element cij is ai1 × b1j + ai2 × b2j + g + ain × bnj. For example, for two 3 × 3 matrices a and b, c is where cij = ai1 * b1j + ai2 * b2j + ai3 * b3j . Write a test program that prompts the user to enter two 3 * 3 matrices and displays their product. Here is a sample run: Ps: pls do the same header and the output is the same on the picture thanksarrow_forwardWrite a menu driven C++ program that should perform following operation on matrices using 2D arrays. (Use OOP Please to write minimum code) The program will first take inputs for both matrices from the user then perform following operations : Subtract() This method will subtract two matrices. Multiply() This method will multiply two matrices but first check number of rows and columns of corresponding matrices and display "Not possible" in case of inequality in rows and columns. AddScalar() This method will add scalar to a matrix by asking user in which matrix to add. CheckTranspose() This method will ask from user which matrix you want to take transpose and then display its transpose. CheckSymmetric() This method will check symmetric matrix CheckIdentity() This method will check if the matrix is identity CheckUpperTriangular() This method will check upper triangular matrix Dont use pointers please use counters only.. Thank you very much. use oop pleasearrow_forward(Sort three numbers) Write the following function to display three numbers in increasing order: def displaySortedNumbers(num1, num2, num3): Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order. Here are some sample runs:arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education