Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Answer the given question with a proper explanation and step-by-step solution.

its all one question. please answer in mips code , the C code is given.

 

Given an array of at least one integer, write a program to create a new array with elements equal to the exponent of each element in the
original array raised to the index, Le, B[i] = sum of 1st/ elements of A
For this, write the following two functions using Procedure Execution. (If procedure execution or functions are not used, you will receive a
score of 0, even if the tests pass).
. main
Following is a sample C code to perform the required task. You may modify the code for the functions, but the task performed should not be
changed
1
. nSum
1
task Create array B by obtaining the sum from the nSum function.
inputs: base address of array A ("A), index of B (k)
task compute the sum of 1st k elements of array A. (If array A elements are overwritten, the updated values should be used.)
return: sum of 1st k elements of array A
int main() (
// Variable
int' A, B:
int n
}
// Task of main function
for (int j = 0; j<nz j++) (
B(11= nSum (A, j);
int main() (
Declaration
int nSum (int. A, int k) (
int aum- A[0];
}
int' A, B:
int n;
// Base addresses of A and B
// Length of arrays A and B
// Variable Declaration
// Task of main
function
for (int j = 0; j<n; j++) {
B[j]nSum (A, j);
// Base addresses of A and B
// Length of arrays A and B
1
return (sum);
int nSum (int. A, int k) (
int sum- A[0];
for (int j = 1; j <-k; j++) {
sum - sum + A[j];
Registers Variables
$50
Ss1
$s2
A
SH0+4
B
n
Addresses Contents
$50
Alo]
All
expand button
Transcribed Image Text:Given an array of at least one integer, write a program to create a new array with elements equal to the exponent of each element in the original array raised to the index, Le, B[i] = sum of 1st/ elements of A For this, write the following two functions using Procedure Execution. (If procedure execution or functions are not used, you will receive a score of 0, even if the tests pass). . main Following is a sample C code to perform the required task. You may modify the code for the functions, but the task performed should not be changed 1 . nSum 1 task Create array B by obtaining the sum from the nSum function. inputs: base address of array A ("A), index of B (k) task compute the sum of 1st k elements of array A. (If array A elements are overwritten, the updated values should be used.) return: sum of 1st k elements of array A int main() ( // Variable int' A, B: int n } // Task of main function for (int j = 0; j<nz j++) ( B(11= nSum (A, j); int main() ( Declaration int nSum (int. A, int k) ( int aum- A[0]; } int' A, B: int n; // Base addresses of A and B // Length of arrays A and B // Variable Declaration // Task of main function for (int j = 0; j<n; j++) { B[j]nSum (A, j); // Base addresses of A and B // Length of arrays A and B 1 return (sum); int nSum (int. A, int k) ( int sum- A[0]; for (int j = 1; j <-k; j++) { sum - sum + A[j]; Registers Variables $50 Ss1 $s2 A SH0+4 B n Addresses Contents $50 Alo] All
Registers Variables
$50
A
$$1
The resultant array B is:
$$2
SS0+4
Addresses Contents
S$0
A[0]
A[1]
Ss0+4 (n-1)
B
n
Example Test: If the values of Ss1 through $57 are initialized in the simulator as: (Use the button under the Registers display to initialize
register values for Ss0, Ss1, $s2 and the + button under the Memory display to initialize the A array elements.)
S$2
Aln-11
Registers Data
$$0
$$1
4000
8000
5
Addresses Contents
4000
10
Registers Data
Ss0
Ss1
$s2
4000
4004
Addresses Contents
10
4008
4012
4016
8004
8008
4000
8012
8000
8016
5
5
Addresses Contents
8000
10
-5
2
0
15
10
8
8
expand button
Transcribed Image Text:Registers Variables $50 A $$1 The resultant array B is: $$2 SS0+4 Addresses Contents S$0 A[0] A[1] Ss0+4 (n-1) B n Example Test: If the values of Ss1 through $57 are initialized in the simulator as: (Use the button under the Registers display to initialize register values for Ss0, Ss1, $s2 and the + button under the Memory display to initialize the A array elements.) S$2 Aln-11 Registers Data $$0 $$1 4000 8000 5 Addresses Contents 4000 10 Registers Data Ss0 Ss1 $s2 4000 4004 Addresses Contents 10 4008 4012 4016 8004 8008 4000 8012 8000 8016 5 5 Addresses Contents 8000 10 -5 2 0 15 10 8 8
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
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