Answer:
1.25
Explanation:
#instructions =
Average CPI (old) = 0.2*6 + 0.8*1 = 1.2+0.8 = 2.0
Average CPI (new) = 0.2*12 + 0.8*1 = 2.4 + 0.8 = 3.2
Assuming Clock Rate = x
Speedup = Execution Time (old) / Execution time (new) = (2.0*5*
/x) / (3.2*5*
/2x) = 4/3.2 = 1.25
Answer:
The function in Python is as follows:
def comparatorValue(a,b, d):
count = 0; test = 0;
for i in a:
for j in b:
if abs (i - j) <= d:
test+=1
if test == 0:
count+=1
test = 0
print(count)
Explanation:
This defines the function
def comparatorValue(a,b, d):
The initializes the count and test to 0
count = 0; test = 0;
This iterates through a
for i in a:
This iterates through b
for j in b:
This calculates absolute difference of elements in a and b. The absolute is then compared to d.
If the calculated difference is less or equal to d, the value is not a comparator value (test in then incremented)
<em> if abs (i - j) <= d:
</em>
<em> test+=1
</em>
The comparison ends here
If test is 0, then the value is a comparator value (count is incremented by 1)
<em> if test == 0:
</em>
<em> count+=1
</em>
Test is set to 0 for another iteration
<em> </em> test = 0
This prints count
print(count)
Answer:
Receiving unexpected results from a program
Explanation:
Logic errors are due to the program not producing a desired result.
I am pretty sure it is the fourth one