Question: Consider the following routine (in Modula-2): procedure SiftDown(var A: array of integer; k, n: integer); var parent, child, insert, Ak: integer; begin parent:= k; child:=

Consider the following routine (in Modula-2):

procedure SiftDown(var A: array of integer; k, n: integer);

var parent, child, insert, Ak: integer;

begin parent:= k; child:= k + k;

Ak:= A[k]; insert:= Ak;

loop if child > n then exit end;

if child < n then if A[child] > A[child+1] then child:= child+1 end end;

if insert <= A[child]

then exit else A[parent]:= A[child];

parent:= child; child:= child + child end end;

A[parent]:= Ak end SiftDown;

(This operation performs the sift-down operation for heaps; if needed, you may consult any text on data structures to learn more about heaps.) The routine is tested using the following input:
n = 5, k = 2, A[1] = 80, A[2] = 60, A[3] = 90, A[4] = 70, A[5] = 10.
Will the above test yield a 100% statement coverage? If not, provide one or more additional test cases this that a 100% statement coverage is obtained.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Software Testing And Quality Assurance Questions!