Concept explainers
A)
Given Information:
The code for matrix transpose routine is given:
//typedef 2-D array declaration
typedef int array[2][2];
//function to perform transpose of matrix
void transpose1(array dst, array src)
{
//variable declaration
int i,j;
//traverse through the rows
for(i=0;i<2;i++) {
//traverse through the elements
for(j=0;j<2;j++) {
//transpose of a matrix
dst[j][i]=src[i][j];
}
}
}
B)
Given Information:
The code for matrix transpose routine is given:
//typedef 2-D array declaration
typedef int array[2][2];
//function to perform transpose of matrix
void transpose1(array dst, array src)
{
//variable declaration
int i,j;
//traverse through the rows
for(i=0;i<2;i++) {
//traverse through the elements
for(j=0;j<2;j++) {
//transpose of a matrix
dst[j][i]=src[i][j];
}
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- 4.1.1 Complete solution and answer only no need explanation Given three data points (1,6), (3,28), and (10, 231), What is the value of y at x = 2 if the function y = 2x2 + 3x + 1 passes through the three data points.arrow_forwardProblem 1) Change the diagonal elements of a 3X3 matrix to 1. Diagonal elements of the example matrix shown here are 10, 8, 2 10 -4 0 7 8 3 0 0 2 Read the given values from input (cin) using for loops and then write your code to solve the diagonal.arrow_forwardR-13.17 - There are eight small islands in a lake, and the state wants to build seven bridges to connect them so that each island can be reached from any other one via one or more bridges. The cost of constructing a bridge is proportional to its length. The distances between pairs of islands are given in the following table. Find which bridges to build to minimize the total construction cost.arrow_forward
- 1. Develop a system of linear equations for the network by writing an equation for each router (A, B, C, D, and E). Make sure to write your final answer as Ax=b where A is the 5x5 coefficient matrix, x is the 5x1 vector of unknowns, and b is a 5x1 vector of constants. 2. construct the augmented matrix [A b] and then perform row reduction using the rref() function. Write out your reduced matrix and identify the free and basic variables of the system. 3. Use MATLAB to compute the LU decomposition of A, i.e., find A = LU. For this decomposition, find the transformed set of equations Ly = b, where y = Ux. Solve the system of equations Ly = b for the unknown vector y. 4. Compute the inverse of U using the inv() function. 5. Compute the solution to the original system of equations by transforming y into x, i.e., compute x = inv(U)y 6. Check your answer for x1 using Cramer’s Rule. Use MATLAB to compute the required determinants using the det() function.arrow_forwardProblem 15 (#2.3.30).If f and f◦g are one-to-one, does it follow that g must be one-to-one? Justify your answer.arrow_forwardProblem 1. Two DNA strands of length 100 (number of bases in the sequence) are given in DNA1.txt and DNA2.txt file. Find the longest common subsequence (LCS) between the two sequences using dynamic programming bottom-up (tabulation) approach. Submit your code to solve the problem. How much time (in seconds or milliseconds) is required by your computer to run the algorithm? Solve the same LCS problem using dynamic programming top-down (memorization) approach. Submit your code to solve the problem. How much time (in seconds or milliseconds) is required by your computer to run the algorithm. Which solution is faster and why? Discuss your solutions.arrow_forward
- VII.Let A = {2, 4, 6, 8}, B = {6, 9}, C = {4, 8}. Answer each of the following questions. Justify your answers. 1. Is B ⊆B?arrow_forward4. Look up the Pythagorean theorem if you are not already familiar with it. Use the following formula to solve for c in the formula: c = √a2 + b2. Use the proper functions from the cmath header file. Be sure to output the result..arrow_forwardI have having issue understanding this example matlab question. Generate the following vectors using the colon operator F = [1 2 3 4 . . . 30] G = [25 22 19 16 13 10 7 4 1] H = [0 0.2 0.4 0.6 . . . 2.0] The colon, :, is one of Matlab’s most important operators.arrow_forward
- (Sparse matrix–vector product) Recall from Section 3.4.2 that a matrix is said to be sparse if most of its entries are zero. More formally, assume a m × n matrix A has sparsity coefficient γ(A) ≪ 1, where γ(A) ≐ d(A)/s(A), d(A) is the number of nonzero elements in A, and s(A) is the size of A (in this case, s(A) = mn). 1. Evaluate the number of operations (multiplications and additions) that are required to form the matrix– vector product Ax, for any given vector x ∈ Rn and generic, non-sparse A. Show that this number is reduced by a factor γ(A), if A is sparse. 2. Now assume that A is not sparse, but is a rank-one modification of a sparse matrix. That is, A is of the form à + uv⊤, where à ∈ Rm,n is sparse, and u ∈ Rm, v ∈ Rm are given. Devise a method to compute the matrix–vector product Ax that exploits sparsity.arrow_forwardProblem 4 Discrete Mathematics.Combinations and Permutations. (5,10,10): Soccer A local high school soccer team has 20 players. However, only 11 players play at any given time during a game. In how many ways can the coach choose 11 players To be more realistic, the 11 players playing a game normally consist of 4 midfielders, 3 defend ers, 3 attackers and 1 goalkeeper. Assume that there are 7 midfielders, 6 defenders, 5 attackers and 2 goalkeepers on the team 2. In how many ways can the coach choose a group of 4 midfielders, 3 defenders, 3 attackers and 1 goalkeeper? 3. Assume that one of the defenders can also play attacker. Now in how many ways can the coach choose a group of 4 midfielders, 3 defenders, 3 attackers and 1 goalkeeper?arrow_forwardProblem 7arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr