Cho thuật toán: Procedure Test(x,i,j: Integer); Var m:integer; Begin m:=trunc(i+j)/2; If x= a<em> then vt:=m Else If (x<a[m]) and ( i<m)

Quốc Tuấn

New member
Cho thuật toán:
Procedure Test(x,i,j: Integer);
Var m:integer;
Begin
m:=trunc(i+j)/2;
If x= a<em> then vt:=m
Else If (x<a[m]) and ( i<m) then Test(x,i,m-1)
Else If ( x> a[m] ) and (j>m) then Test(x,m+1,j)
Else vt:=0;
End;
Với A = {5, 2, 9 ,8, 6, 4, 7,1}. Kết quả nào đúng trong số những kết quả dưới đây:
A. Test(3,1,8), vt = 0;
B. Test(4,1,8), vt = 5;
C. Test(6,1,8), vt = 0;
D. Test(7,1,8), vt = 8;