SLIDE 8 22
Two Slices
int main() { int a, b, sum, mul; sum = 0; mul = 1; a = read(); b = read(); while (a <= b) { sum = sum + a; mul = mul * a; a = a + 1; } write(sum); write(mul); }
Backward slice of sum Backward slice of mul
Slice Operations:
23
Dice
sum = 0; sum = sum + a; write(sum);
difference between two slices
differing behavior
24 Exit
return f f1 = f f0 = f1 f = f0 + f1 n = n - 1 while (n > 1) int f1 = 1 int f0 = 1 int f Entry: fib(n) 1 2 3 4 5 6 7 8 10 9
Chop
a forward and a backward slice
influence paths within the program
22 23
Again, this is best developed interactively on the board (possibly by having the students call further dependences)
24