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
Question
Chapter 6.2, Problem 6.7PP
Program Plan Intro
Given Information:
The sample program for sum of a 3-D array is given below:
// Sum of a 3-dimensional array
int sumarray3d(int a[N] [N] [N])
{
//variable declaration
int i,j,k, sum=0;
//Traverse the array
for(i=0;i<n;i++)
{
for(j=0;j>N;j++)
{
for(k=0;k<N;k++)
{
//sum of all the array elements
sum = sum+ a[k][i][j];
}
}
}
return sum;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(8).
an array of integers nums and an integer target, return the indices of the two numbers such that they add up to the target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.
Explain also.
(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.
a-d please
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
Similar questions
- 4. Use NumPy's arange function to create vectors identical to the following created with the linspace function: (a) np.linspace (-2,1.5,8) (b) np. linspace (8,4.5,8)arrow_forward(Python)Given an array, construct a BST. Use the BST to find the predecessor q(Largest element, but no larger than q). Here is my code for finding predecessor q after constructing the BST. The problem is when q equals to one of the number in the BST, it does not return that number. For example, an array [47,25,23,81,59] with q = 81 should return 81. My program return 59.arrow_forward7. Consider the sample program array max.cpp. (a) Clearly describe the changes necessary to find the minimum value in the array. (b) Explain how to test your answer to (a).arrow_forward
- Source computer sources.. 33.arrow_forwardAnswer the given question with a proper explanation and step-by-step solution. please only add to code where it says " add code below this line" C++ pleasearrow_forward(Paths in Graphs) Graph theory studies sets of vertices connect by edges. A very simple way to store the connectivity information about a graph is using what is called an adjacency malrir. In an adjacency matrix A, entry aij is 1 if nodes i and j are connected by an edge and is 0 otherwise. For example, the graph below has adjacency matrix [0 1 1 01 101 0 A = 1 10 1 o o 10 3 One interesting calculation that can casily be done using an adjacency matrix is that we can count the number of paths between two nodes in the graph by calculating powers of the matrix. For example, because 1 11] 1 2 1 1 1 1 3 0 1 10 1 we know that there are 0 paths of length 2 from node 3 to node 4 because the entry in row 3, column 4 of A is a 0. find num_paths Function: Input parameters: • a square adjacency matrix • a scalar representing the desired path length • two scalars representing the two nodes Output parameters: • a scalar representing the number of paths connecting the two desired nodes of the desired…arrow_forward
- PYTHON/ COMPUTATIONAL STOICHIOMETRY Please help me build the stochiometric matrix for the chemical reaction.kindly use the code provided to guide your solution. 1.7 A + 2.1 B + 1.5 C <=> 3 D + 3.8 E + 1.2 F Code Block to build stoichiometric matrix: import numpy as np # Initialize the stoichiometric matrix as zeros_mtrx = np.zeros((len(reactions), len(species))) for (i_row, r) in enumerate(reactions): left = r.split('<=>')[0].strip() right = r.split('<=>')[1].strip() left_terms = left.split('+') left_terms = [t.strip() for t in left_terms] # in-place clean up right_terms = right.split('+') right_terms = [t.strip() for t in right_terms] # in-place clean up for t in left_terms: # reactants tmp = t.split(' ') # split stoichiometric coeff and species name if len(tmp) == 2: # stoich coeff and species name coeff = float(tmp[0].strip()) species_member = tmp[1].strip() j_col…arrow_forwardM. 0om question 6.arrow_forward2.arrow_forward
- Using C++ write code for the following and call from a main function (a) A function that via its parameter list, receives a one-dimensional array of an arbitrary ( i.e. []) size, of type double and populates it with random positive doubles only in the range 0.0 and 9.0. Show how to pass array size also in parameter list to this function. (b) A function that via its parameter list receives a one-dimensional array of arbitrary size of type double and returns the average of the elements in the array via a double return variable. Enforce that the function may not change the array or size parameter data passed to it in any way. (c) A function that receives via its parameter list a one-dimensional array of arbitrary size, containing type double and prints its elements. Enforce that the function may not change the array or size parameter data passed to it in any way. (d) Write a main function in which you show how to call the functions in parts (a), (b), and (c) above. You may only declare…arrow_forward| The code in Part 1 counts the crossings and nestings for a given matching. We now want to use this to analyze the distribution of crossings and nestings for arc diagrams with 100 arcs. Using your function random_matching from Exercise [1.4], generate 104 such arc diagrams and create histograms for the numbers of crossings and nestings, respectively. Display them in a single plot. Also generate a two-dimensional histogram for the joint distribution of crossings and nestings. What do you observe?arrow_forwardThis is not a graded question so please don't disregard it as if it is. Thank you in advance professor!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning