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!