soc
Junior Member level 3
Hello,
I want to know the correct answer for the following problems,since these were part of exam and just want to know if I did right and if wrong ,then like to know the correct solution.
Thanks
1.what will be the CDFG and the longest and shortest path for the given code,assuming each execution takes one time unit
n = 5;
if (a < b)
n = 4;
for (i = 0; i < n; i++) {
if (c > 0)
x++;
else {
x--;
y++;
}
}
2.Code optimisation
a) only optimisations are allowed that do not increase the code size
b)all optimisations are allowed.
int a[10], b[10], c[10];
// ...
int f() {
int i;
for(i = 1; i < 10; i++)
a = b + c;
}
int g(int n) {
int y = 0;
int i;
for(i = 1; i < 2*n; i++)
y += c;
return y;
}
int main() {
// ...
f();
y = g(5);
// ...
}
I want to know the correct answer for the following problems,since these were part of exam and just want to know if I did right and if wrong ,then like to know the correct solution.
Thanks
1.what will be the CDFG and the longest and shortest path for the given code,assuming each execution takes one time unit
n = 5;
if (a < b)
n = 4;
for (i = 0; i < n; i++) {
if (c > 0)
x++;
else {
x--;
y++;
}
}
2.Code optimisation
a) only optimisations are allowed that do not increase the code size
b)all optimisations are allowed.
int a[10], b[10], c[10];
// ...
int f() {
int i;
for(i = 1; i < 10; i++)
a = b + c;
}
int g(int n) {
int y = 0;
int i;
for(i = 1; i < 2*n; i++)
y += c;
return y;
}
int main() {
// ...
f();
y = g(5);
// ...
}