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
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.
C) Assume that the main contains the definition of the following variables and/or constants:
int mat[NR][NC];
int i=0, j=0, "pi=&i, *pj=&j;
Which of the following function calls contain errors? (Say why)
1. moveIndexes (mat, &i, &j, NC);
2. moveIndexes (mat, pi, pj, NR);
3. moveIndexes (mat, *pi, *pj, NR);
4. moveIndexes (mat, i, j, NC);
B
三
A) delta represents an increase or a decrease: of what? (Explain your answer)
1. of row? (Justify your answer)
2. of column? (Justify your answer)
3. other (What? Justify your answer)
B) Given *rp=3 and *cp=4, delta=12, which values will be assigned to *rp and *cp at the end of function execution?
(Justify your answer or show intermediate results)
*rp =
*cp =
C) Which of the following function calls contain errors? (Say why)
1. moveIndexes (mat, &i, Ej,NC);
2. moveIndexes (mat, pi,pj,NR);
3. moveIndexes (mat, pi, *pj,NR);
4. move Indexes (mat, i,j, NC) ;
expand button
Transcribed Image Text:C) Assume that the main contains the definition of the following variables and/or constants: int mat[NR][NC]; int i=0, j=0, "pi=&i, *pj=&j; Which of the following function calls contain errors? (Say why) 1. moveIndexes (mat, &i, &j, NC); 2. moveIndexes (mat, pi, pj, NR); 3. moveIndexes (mat, *pi, *pj, NR); 4. moveIndexes (mat, i, j, NC); B 三 A) delta represents an increase or a decrease: of what? (Explain your answer) 1. of row? (Justify your answer) 2. of column? (Justify your answer) 3. other (What? Justify your answer) B) Given *rp=3 and *cp=4, delta=12, which values will be assigned to *rp and *cp at the end of function execution? (Justify your answer or show intermediate results) *rp = *cp = C) Which of the following function calls contain errors? (Say why) 1. moveIndexes (mat, &i, Ej,NC); 2. moveIndexes (mat, pi,pj,NR); 3. moveIndexes (mat, pi, *pj,NR); 4. move Indexes (mat, i,j, NC) ;
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 movelndexes (int M[NR][NC], int *rp, int *cp, int delta) {
int i, j, *p, *p0;
i = *rp;
j = *cp;
if (i<0 || i>=NR || j<0 \[ j>=NC)
return 1; // error
nothing done
p0 = & (M[] [0]);
p = & (M[i [5]);
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?
3. other (what?)
B) Given *rp3D3 and cp=4, delta=12, which values will be assigned to rp and cp at the end of function execution? (Justify
your answer or show intermediate results)
C) Assume that the main contains the definition of the following variables and/or constants
int mat [NR] [NC];
expand button
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 movelndexes (int M[NR][NC], int *rp, int *cp, int delta) { int i, j, *p, *p0; i = *rp; j = *cp; if (i<0 || i>=NR || j<0 \[ j>=NC) return 1; // error nothing done p0 = & (M[] [0]); p = & (M[i [5]); 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? 3. other (what?) B) Given *rp3D3 and cp=4, delta=12, which values will be assigned to rp and cp at the end of function execution? (Justify your answer or show intermediate results) C) Assume that the main contains the definition of the following variables and/or constants int mat [NR] [NC];
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.
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