delta represents an increase or a decrease: of what? (Explain your answer)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
This is not a graded question so please don't disregard it as if it is.Thank you in advance professor! Note: This is a THEORETICAL QUESTION and no code should be used for solving it.
You are given the following function moveIndexes, where NR and NC are numerical constants. The function receives as
parameters rp and cp, two pointers to int. The goal of the function is to modify the values pointed by rp and cp as follows: if
rp and cp originally point to the indexes of a certain cell of the matrix, after function invocation they must point to the indexes of
a cell at a distance delta from the original one.
int moveIndexes (int M[NR] [NC], int *rp, int *cp, int delta) {
int i, j, "p, *p0;
i = *rp;
j = *cp;
if (i<0 |1 i>=NR || j<0 |[ j>=NC)
return 1; // error -
nothing done
p0 = & (M[0] [0]);
p = & (M[i]][j]);
p= p+delta;
if (p < p0 || p > & (M[NR-1] [NC-1]))
return 1; // error - nothing done
*rp = (p - p0) / NC;
*cp = (p - p0) % NC;
return 0;
Assume that NR and NC are equal to 10, that addresses are represented with 32 bits, and that sizeof (int) is equal to 4.
Answer the following questions:
A) delta represents an increase or a decrease: of what? (Explain your answer)
1. of row?
2. of column?
B) Given *rp%3D3 and *cp=D4, delta=12, which values will be assigned to rp and ep at the end of function execution? (Justify
your answer or show intermediate results)
3. other (what?)
Transcribed Image Text:You are given the following function moveIndexes, where NR and NC are numerical constants. The function receives as parameters rp and cp, two pointers to int. The goal of the function is to modify the values pointed by rp and cp as follows: if rp and cp originally point to the indexes of a certain cell of the matrix, after function invocation they must point to the indexes of a cell at a distance delta from the original one. int moveIndexes (int M[NR] [NC], int *rp, int *cp, int delta) { int i, j, "p, *p0; i = *rp; j = *cp; if (i<0 |1 i>=NR || j<0 |[ j>=NC) return 1; // error - nothing done p0 = & (M[0] [0]); p = & (M[i]][j]); p= p+delta; if (p < p0 || p > & (M[NR-1] [NC-1])) return 1; // error - nothing done *rp = (p - p0) / NC; *cp = (p - p0) % NC; return 0; Assume that NR and NC are equal to 10, that addresses are represented with 32 bits, and that sizeof (int) is equal to 4. Answer the following questions: A) delta represents an increase or a decrease: of what? (Explain your answer) 1. of row? 2. of column? B) Given *rp%3D3 and *cp=D4, delta=12, which values will be assigned to rp and ep at the end of function execution? (Justify your answer or show intermediate results) 3. other (what?)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Troubleshooting
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education