Question

In: Computer Science

Given the existence of two-dimensional array double A[M][N], where M and N are #defined as the...

Given the existence of two-dimensional array double A[M][N], where M and N are #defined as the number of rows and columns, respectively, define a function named sqabsmax that accepts array A as an argument (i.e. input parameter) and returns the square of the maximum absolute value element in A. Use the const qualifier if appropriate. Only show the function definition. Do not write an entire program with a main function. Just write the definition for function sqabsmax.

in C

Solutions

Expert Solution

const double sqabsmax(double A[][N])
{
        double maximum = fabs(A[0][0]);
        
        int c=0,d=0;
         for (c = 0; c < M; c++)
        for (d = 0; d < N; d++)
                if (fabs(A[c][d]) > maximum)
                        maximum = fabs(A[c][d]);
                        
      return maximum*maximum; //square of the maximum absolute value
                        
}


Related Solutions

Create a function to output a one dimensional double array Mwith n elements where the...
Create a function to output a one dimensional double array M with n elements where the first three elements are 1 and each subsequent element is the sum of previous three elements before it. Name the function myArray. Write the function in the correct format to be used to create a Matlab function. Call the function in correct format to output the array with 7 elements.
you will create a dynamic two dimensional array of mult_div_values structs (defined below). The two dimensional...
you will create a dynamic two dimensional array of mult_div_values structs (defined below). The two dimensional array will be used to store the rows and columns of a multiplication and division table. Note that the table will start at 1 instead of zero, to prevent causing a divide-by-zero error in the division table! struct mult_div_values { int mult; float div; }; The program needs to read the number of rows and columns from the user as command line arguments. You...
Given an m × n matrix (or 2-dimensional array) whose rows and columns are sorted, so...
Given an m × n matrix (or 2-dimensional array) whose rows and columns are sorted, so A[i][j]≤ A[i][j+1] and A[i][j]≤ A[i+1][j] Write an algorithm that searches for a specific value in the matrix.
Given an array A[0 … n-1], where each element of the array represent a vote in...
Given an array A[0 … n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.
Problem 1: Given an array A[0 ... n-1], where each element of the array represents a...
Problem 1: Given an array A[0 ... n-1], where each element of the array represents a vote in the election. Assume that each vote is given as integers representing the ID of the chosen candidate. Write the code determining who wins the election. Problem 2: How do we find the number which appeared maximum number of times in an array? ( Use Java and an original code )
Using Java, Given an array A[0 ... n-1], where each element of the array represent a...
Using Java, Given an array A[0 ... n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.
C++ ASSIGNMENT: Two-dimensional array Problem Write a program that create a two-dimensional array initialized with test...
C++ ASSIGNMENT: Two-dimensional array Problem Write a program that create a two-dimensional array initialized with test data. The program should have the following functions: getTotal - This function should accept two-dimensional array as its argument and return the total of all the values in the array. getAverage - This function should accept a two-dimensional array as its argument and return the average of values in the array. getRowTotal - This function should accept a two-dimensional array as its first argument...
Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float- point type and the two constants...
Given that Sale[NUM_ROW][NUM_COLUMN] is a two dimensional array of float- point type and the two constants are defined as follows: #define NUM_ROW 4 #define NUM_COLUMN 4 float Value[NUM_ROW][NUM_COLUMN] = { 2.1, 2.2, 2.3, 2.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.1, 2.2, 2.3, 2.4 }; Write a C++ main function that computes and prints out the following information about this 2d array: (1) The mean of all the Value[][] array elements (0.5 points). (2) The median of all...
Use NumPy to create a My_Array; a 3 by 3 array where in,m = n +...
Use NumPy to create a My_Array; a 3 by 3 array where in,m = n + m. (e.g., the first row first column would be 0+0=0, second row first column would be 1+0=1, etc). complete the following using NumPy: Compute the mean, median, range, and variance of this array Find the inverse or pseudo inverse Find the determinant Perform the following operations on My_Array Create My_1D_Array by reshaping My_Array into a 1-dimensional array Create a new array that is the...
//2.-------------------------------------------------------------- Given an array of size N, what is the complexity? int m = A[0]; for...
//2.-------------------------------------------------------------- Given an array of size N, what is the complexity? int m = A[0]; for (int i=1; i<N; i++) { if (A[i] > m) m = A[i]; } int k = 0; for (int i=0; i<N; i++) { if (A[i] == m) k++; } What is a (name one) most frequent operation performed?______________________ Expression showing the number of times it is performed ___________ Time Complexity in Big-O Notation O( ) _____________________________________________________ //3.-------------------------------------------------------------- int mult(int N, int M) {   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT