Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions algorithms/Searching/binary_search.m
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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