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, Problem 6.37HW
Program Plan Intro

Given Information:

Three different functions are given:

// declare 2-D array

typedef int array_t[N][N];

// function to add values of 2-D array

int sumA(array_t a) {

// variable declaration

int i, j;

int sum = 0;

// traverse through rows

for (i = 0; i < N; i++)

// traverse through elements

for (j = 0; j < N; j++) {

// sum of elements

sum = sum + a[i][j];

}

// return sum

return sum;

}

// function to add values of 2-D array

int sumB(array_t a) {

// variable declaration

int i, j;

int sum = 0;

// traverse through columns

for (j = 0; j < N; j++)

// traverse through rows

for (i = 0; i < N; i++) {

// sum of elements

sum = sum + a[i][j];

}

// return sum

return sum;

}

// function to add values of 2-D array

int sumC(array_t a)

{

//variable declaration

int i,j;

int sum=0;

//traverse through columns

for(j=0;j<N;j+=2)

//traverse through rows

for(i=0;i<N;i+=2)

{

//sum of elements

sum+=(a[i][j]+a[i+1][j]+ a[i][j+1]+a[i+1][j+1]);

}

//return sum

return sum;

}

Blurred answer
Students have asked these similar questions
A 2-way set associative cache consists of four sets. Main memory contains 2K blocks of eight words each. Show the main memory address format that allows us to map addresses from main memory to cache. Be sure to include the fields as well as their sizes. Compute the hit ratio for a program that loops 6 times from locations 8 to 51 in main memory. You may leave the hit ratio in terms of a fraction. Please show details how you obtain the result.
3. The table below represents five lines from a cache that uses fully associative mapping with a block size of 8. Identify the address of the shaded data, 0xE6, first in binary and then in hexadecimal. The tag numbers and word id bits are in binary, but the content of the cache (the data) is in hexadecimal.                   Word id bits Tag 000 001 010 011 100 101 110 111 ------------------------------------------ 1011010 10 65 BA 0F C4 19 6E C3 1100101 21 76 CB 80 D5 2A 7F B5 0011011 32 87 DC 91 E6 3B F0 A6 1100000 43 98 ED A2 F7 4C E1 97 1111100 54 9A FE B3 08 5D D2 88
A 2-way set-associative cache consists of four sets. Main memory contains 2K blocks of 8 bytes each and byte addressing is used.Q.) Compute the hit ratio for a program that loops three times from addresses 0x8 to 0x33 in main memory. You may leave the hit ratio in terms of a fraction.
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