Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 6, Problem 6.45HW
Program Plan Intro
Given Information:
The given code is:
//method to transpose matrix
void transpose(int *dst, int *src, int dim)
{
//variable declaration
int i,j;
//traverse through matrix
for(i=0;i<dim;i++)
for(j=0;j<dim;j++)
//transpose
dst[j*dim+i]=src[i*dim+j];
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a procedure called STRUCTURE-TO-MATRIX that takes an adjacency structure as its only parameter, and returns an equivalent adjacency matrix. Assume there is a procedure MAKE-MATRIX(m, n) that returns an m × n integer matrix, where m ≥ 0 and n ≥ 0. The integers in this matrix are undefined.
in c++ please
Write a function called Replace All that cerpts two parameters a matrix of 100 elements of type inter and an interval
y. The function must
- Replace every positive matrix element by the values +5and
Replace every negative matrix element by the value - 5 and
- Replace every mero try the value y.
Implement the Transpose pseudocode to C++ program. Your program should ask the size of the matrix and will ask for the elements/item of the two dimensional array. The elements of the original matrix and its transpose will be displayed in ROW-WISE method by your program.
Chapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 6.1 - Prob. 6.1PPCh. 6.1 - Prob. 6.2PPCh. 6.1 - Prob. 6.3PPCh. 6.1 - Prob. 6.4PPCh. 6.1 - Prob. 6.5PPCh. 6.1 - Prob. 6.6PPCh. 6.2 - Prob. 6.7PPCh. 6.2 - Prob. 6.8PPCh. 6.4 - Prob. 6.9PPCh. 6.4 - Prob. 6.10PP
Ch. 6.4 - Prob. 6.11PPCh. 6.4 - Prob. 6.12PPCh. 6.4 - Prob. 6.13PPCh. 6.4 - Prob. 6.14PPCh. 6.4 - Prob. 6.15PPCh. 6.4 - Prob. 6.16PPCh. 6.5 - Prob. 6.17PPCh. 6.5 - Prob. 6.18PPCh. 6.5 - Prob. 6.19PPCh. 6.5 - Prob. 6.20PPCh. 6.6 - Prob. 6.21PPCh. 6 - Prob. 6.22HWCh. 6 - Prob. 6.23HWCh. 6 - Suppose that a 2 MB file consisting of 512-byte...Ch. 6 - The following table gives the parameters for a...Ch. 6 - The following table gives the parameters for a...Ch. 6 - Prob. 6.27HWCh. 6 - This problem concerns the cache in Practice...Ch. 6 - Suppose we have a system with the following...Ch. 6 - Suppose we have a system with following...Ch. 6 - Suppose that a program using the cache in Problem...Ch. 6 - Repeat Problem 6.31 for memory address0x16E8 A....Ch. 6 - Prob. 6.33HWCh. 6 - Prob. 6.34HWCh. 6 - Prob. 6.35HWCh. 6 - Prob. 6.36HWCh. 6 - Prob. 6.37HWCh. 6 - Prob. 6.38HWCh. 6 - Prob. 6.39HWCh. 6 - Given the assumptions in Problem 6.38, determine...Ch. 6 - You are writing a new 3D game that you hope will...Ch. 6 - Prob. 6.42HWCh. 6 - Prob. 6.43HWCh. 6 - Prob. 6.45HWCh. 6 - Prob. 6.46HW
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a code to create a QR decomposition of the matrix A by utilizing the code developed in the previous sub-parts of this question. Find the matrices Q and R and then display the value ∥A − (Q.R)∥F , where ∥ · ∥F is the Frobenius norm. The code should also display the total number of additions, multiplications and divisions to find the result. Deliverable(s) : The code with the said input and output. The results obtained for A generated with m = 7 and n = 5 with random entries described above.arrow_forwardWrite a user-defined function that determines the value that occurs most often in a set of data that is given in a two-dimensional matrix. For the func- tion name and arguments, use [v, q] =matrixmode (x). The input argu- ment x is a m×n matrix of any size with numerical values, and the output arguments v and q are the values that occur most often and the number of times they occur. If there are two, or more, values that occur most often than v is a vector with these values. Do not use the MATLAB built-in func- tion mode. Test the function three times. For input create a 5×6 matrix using the following command: x=randi (10,5,6).arrow_forwardWrite a function max_matrix(M) that takes in a non-empty matrix (a 2-dimensional array) of real numbers M and returns its maximum value. You must use loops in your code. In pythonarrow_forward
- link to MINST code: https://www.dropbox.com/s/i21pedejv0sknnq/MINST.pdf?dl=0 1) Add a confusion matrix to the MNIST code example from the link provided. Set the epochs parameter to 5. Explain which entry of the matrix yields the number of ones (the number 1) that are falsely recognized as eights (the number 8). (If you use indices in your explanation, use the Python index notation, i.e., start at zero.) Run your code a few times. Is the confusion matrix always the same? Briefly explain.arrow_forwardPassing multidimensional arrays to a functionMultidimensional arrays follow the same rules as single-dimensional arrays when passing them to a function.However the combination of decay-to-pointer, operator precedence, and the two different ways to declare amultidimensional array (array of arrays vs array of pointers) may make the declaration of such functions nonintuitive. Write code example shows the correct ways to pass multidimensional arrays.arrow_forwardCode in C. Solve the code below. Write a function that takes a vector of integers, an integer n representing the number of elements in that vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The sequential search works as follows: you must look at all the elements of the vector until you find the b, from the first to the last. The function must return an integer representing how many elements the function tested until it found b. If it does not find the function, it must return 0. The name of the function must be called "busca_seq". int busca_seq(int vetor[], int n, int b) { //your code } My Code #include<stdio.h> int busca_seq(int vetor[], int n, int b) { int i; for(i = 0; i < n; i++){ if(vetor[i] == b) return (i+1); } { int vet[5],n = 5,b,x; vet[0] = 1; vet[1] = 2; vet[2] = 3; vet[3] = 4; vet[4] = 5; scanf("%d",&b); x = busca_seq(vet,n,b); printf("%d",x); return 0; } }arrow_forward
- Write a driver function which initializes two rectangular matrices and multiplies them together. Remember that two matrices can be multiplied only if the number of columns of the first matrix is equal to the number of rows of the second matrix (i.e. A[n,m] X B[m,p] = C[n,p]).arrow_forwardWrite a C program for Making a diagonal Matrix:A diagonal matrix is a square matrix in which all the elements that are NOT in the principal diagonal arezeros.Consider a 3*3 (row* col) matrix with the value follows,{1,2, 3}, {4,5, 6),{ 7, 8, 9}Your task is to make it a Diagonal matrix.Please crate two function - 1) printMatrix to print the entire Matrix. 2) makingDiagonal to transformthe matrix into diagonal. Check the image for sample output:arrow_forwardMarked Problems. Complete an implementation for the following prototype of a function that searches for a student with a given ID in an array of students. If the student was found, the function should return a pointer to the student's name. If no student with that ID exists in the array then the function should return NULL. Your function must run in O(n) time in the worst case and O(1) time in the best case where n is the number of student records in the array. // // find_id(id, arr, n) searches for a student with given id in arr; returns a pointer to the student's name or NULL if no student has the given id // // requires: arr has length n // char * students in arr have unique ids find_id (int id, struct student * arr[], int n) ; Complete an implementation for the "inverse" lookup, i.e., a function that searches for students with a given name. Note that many students might share the same name. Your function must run in O(nm) time where n is the number of student records in the array…arrow_forward
- Write a C++ program that will dynamically allocate a 2D array of size MxN, where M and N will be entered by the user. Program should fill the MxN matrix according to the following criteria: Generate random numbers in the range 120 to 340 and fill the diagonal entries in the matrix. Each element in the upper triangular matrix will be calculated by adding its left and bottom neighbor elements. Each element in the lower triangular matrix will be calculated by subtracting the top element from the element on the right. Element in Upper Triangular Matrix = Left Element + Bottom Element Element in Lower Triangular Matrix Right Element - Top Element (A sample 5x5 matrix is filled for you ) 89 500 1100 1955 3886 322 411 600 855 1931 544 -222 189 255 1076 643 99 -123 66 821 70 713 812 689 755 Program will display the filled matrix in tabular form on the screen and delete the dynamically allocated 21 array before terminating.arrow_forwardThe main function, which calculates the row and column averages separately in the two-dimensional array of M × N size given to him, and calculates the row and column averages of which the difference is the smallest, taking into account these averages, and finds the row and column indices where the difference between them is the smallest. Write it in C language. Access to array elements and permissions must be made with pointers to be defined separately. Indexing (matrix (i) (j) array (j) etc.) should not be used. All array operations to be used will be processed with an external pointer, not indexing. Solutions that access the elements of arrays by indexing without using pointers will not be accepted. The number of rows and columns of the given two-dimensional array (matrix) will be different.arrow_forwardA matrix of characters schematically represents a swamp. The swamp is composed of muddy areas, represented with the character, and rocky areas, represented with the *' character. The matrix size can be defined using #define, however it should be no greater than 25 rows and 80 columns. Example of swamp: Write a C program that searches a path in the swamp, from the left to the right, without jumps, only including consecutive rocky areas. Suppose that each rocky area can have at most one other rocky area on its right (there are no branches), i.e., either on the same row, or in the previous row, or in the following one. The program shall print the row sequence of the path (the columns are implicit – there shall be a rocky area for each column), or report that no path exists. For example: 1 3 4 Path: 23 43 43 2 3 4 3 4 Hint: in a preliminary version, use a predefined matrix of strings and test the program; then modify the program and read the swamp from the keyboard input (in the future it…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education