diff --git a/algorithms/Searching/binary_search.m b/algorithms/Searching/binary_search.m index d2e6514..440a979 100644 --- a/algorithms/Searching/binary_search.m +++ b/algorithms/Searching/binary_search.m @@ -14,7 +14,7 @@ L_SearchRange = 1; %initial search range R_SearchRange = array_length; -while counter <= floor(log(array_length))+1 %maximum iteration needed to find the target +while counter <= floor(log2(array_length))+1 %maximum iteration needed to find the target mid = (L_SearchRange + R_SearchRange)/2; if t == A(floor(mid)) @@ -31,7 +31,7 @@ counter = counter+1; end end -if counter > floor(log(array_length))+1 +if counter > floor(log2(array_length))+1 disp('target is not found in aray') end end