以下程序段
for i:=1 to n do begin
h:=1;r:=n;m:=(h+r) div 2;
while (h<=r) and (a[i]<>b[m]) do begin
if a[i]>b[m]
then h:=m+1
else r:=m-1;
m:=(h+r) div 2;
end;
if a[i]=b[m] then writeln(‘Yes’) else writeln(‘NO’);
end;
该程序段中算法的时间复杂度为( )
- A.O(logn)
- B.O(nlogn)
- C.O(n)
- D.O(n^2)
|