Computer Systems: A Programmer's Perspective (3rd Edition)
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
Question
Book Icon
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;

}

Blurred answer
Students 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.  
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)
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education