Debugging help for the exponential search code below
古いコメントを表示
function [ Ind] = exponSearch(arr, n, x)
if arr(0) == x
currentIndex = 0;
end
i=1;
while i<n && arr(i) <= x
i= i.*2;
Ind = binSearch(V, i/2, min(i,n), x);
end
function Cind = binarySearch(V, l, r, x)
if r >= l
mid = ceil(l+(r-l)/2);
if V(mid) == x
end
%if the target is smaller than the middle element
if V(mid) >x
Cind= binSearch(V, l, mid-1,x);
disp(Cind);
end
Cind = binSearch(V,mid+1,r,x);
end
end
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!