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

Homework #11, Control Flow Coverage For the following program P written in pseud

ID: 3686521 • Letter: H

Question

Homework #11, Control Flow Coverage For the following program P written in pseudo-code, given the test set T: T = {t1 = <7, 2>, t2 = <3, 1>}

1) What is the domain for statement coverage of P? Do not include syntactical markers.

2) What is the statement coverage for T?

3) What is the domain for block coverage of P?

4) What is the block coverage for T?

5) What is the domain for decision coverage of P?

6) What is the decision coverage for T?

7) What is the domain for condition coverage of P?

8) What is the condition coverage for T?

9) What is the domain for linear code sequence and jumps (LCSAJs) coverage of P?

10) What is the LCSAJ coverage for T?

Program P

1) integer X, Y, Z;

2) input (X, Y);

3) if (X<0 or X>8 or Y<1 or Y>3)

4) {

5) output (“Boundary condition failure on inputs.”);

6) } // end input check

7) else

8) {

9) Z = 0;

10) if (X < 5)

11) {

12) Z = X + Y;

13) if (Y == 1)

14) {

15) Z = X ^ 2;

16) } // end if (Y==1)

17) } // end if (X<5)

18) else

19) {

20) Z = Z – X;

21) if (Y == 0)

22) {

23) Z = Z * Z;

24) } // end if (Y==2)

25) else

26) {

27) Z = Z + X;

28) } // end else !(Y==2)

29) } // end else !(X<5)

30) output (X,Y,Z);

31) } // end else legal inputs

32) end;

Explanation / Answer

The statement coverage of T with respect to P is Sc / (Se Si ), where Sc is the number of statements covered, Si is the number of unreachable statements, and

Se is the total number of executable statements in the program, i.e., the size of the coverage domain

1) Coverage domain: Se = {2, 3, 5, 9, 10, 12, 13, 15, 20, 21 ,23. 27, 30 }

2) What is the statement coverage for T?

Statements covered: t1 <7, 2> : { 2, 3, 9, 20, 27, 30}

t2 <3, 1>: { 2, 3,9, 10, 12, 13 , 15 , 27,30 }

Sc = 10,, Se = 13,   Si = { 5,21,23}= 3

The statement coverage for T1 is 10 / (13 3) = 1

3) What is the domain for block coverage of P?

The block coverage of T with respect to P is Bc / (Be Bi ), where Bc is the number of blocks covered, Bi is the number of unreachable blocks, and Be is the total number of executable blocks in the program, i.e., the size of the block coverage domain.    A basic block is a sequence of consecutive statements that has exactly one entry point and one exit point .  Be= 9 ={ {1,2,3,}, { 5 } , { 9,10 }. {12,13}. { 15}, {20,21}, {23}, {27}, {30} }

4) What is the block coverage for T?

The block coverage of T with respect to P is Bc / (Be Bi ),

Bc = 7, Be = 9 , Bi = 2. The block  coverage for T1 is 7 / (9 2) = 1

5) What is the domain for decision coverage of P?

A decision is considered covered if the flow of control has been diverted to all possible destinations that correspond to this decision, i.e., all outcomes of the decision have been taken.

6) What is the decision coverage for T?

The decision coverage of T with respect to (P, R) is computed as Dc / (De Di ), where Dc is the number of decisions covered. Di is the number of infeasible decisions, and De is the total number of decisions in the program, i.e., the size of the decision coverage domain. T is considered adequate with respect to the decision coverage criterion if the decision coverage of T with respect to (P, R) is 1.

7) What is the domain for condition coverage of P?

Ce is the total number of simple conditions in the program.

8) What is the condition coverage for T?

The condition coverage of T with respect to (P, R) is computed as Cc / (Ce Ci ) , where – Cc is the number of simple conditions covered, – Ci is the number of infeasible simple conditions, and – Ce is the total number of simple conditions in the program.

9) What is the domain for linear code sequence and jumps (LCSAJs) coverage of P?

code coverage, which begins at the start of the program or branch and ends at the end of the program or the branch.

10) What is the LCSAJ coverage for T?

An LCSAJ is represented as a triple (X, Y, Z) where X and Y are, respectively, locations of the first and the last statements and Z is the location to which the statement at Y jumps.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote