Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

y = 7; // node 1 while ( x < 0 ) // node 2 { input y; // node 3 if (y < x + 7);

ID: 3837144 • Letter: Y

Question

y = 7; // node 1

while ( x < 0 ) // node 2

{

input y; // node 3

if (y < x + 7); // node 4

{

x-= y; // node 5

}

print y; // node 6

}

print x; // node 7

b) (2 points) Which places are the variable x defined? c) (2 points) Which places are the variable y defined? d) (2 points) Which places are the variable x used? e) (2 points) Which places are the variable yused? (4 points) Give all of the du-paths for variables x and y. g) (4 points) Give the test requirements for al-uses coverage. h) (4 points) Consider the following test paths. Create a matrix that gives test paths as rows and du-paths for variable x as columns. For each box in the matrix, mark the box with a 't' if that test path tours that du-path with a direct tour, with an 's' if it tours it with a side trip, or with a 'd' if it tours it with a detour. Otherwise, leave the box blank. T1: 1,2,71 2: 1,2,3,4,6,2,71 T3: 1,2,3,4,5,6,2, 71 T4: 3,4,5,6,2,7] Ts 1,2,3,4,6,2,3,4,6,2,7 i) (4 points) What is a minimal set of test paths that achieves all-du-paths coverage for variable x using direct tours only.

Explanation / Answer

[b] At Node 1
[c] At node 3
[d] At Node 2/4/6
[e] At Node 4/5/7
[f] Var X -> Node 2-->5-->6
     Var Y -> Node 3-->4-->7