We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f22da2b commit 52baa3fCopy full SHA for 52baa3f
algorithms/Searching/binary_search.m
@@ -14,7 +14,7 @@
14
L_SearchRange = 1; %initial search range
15
R_SearchRange = array_length;
16
17
-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
18
mid = (L_SearchRange + R_SearchRange)/2;
19
20
if t == A(floor(mid))
@@ -31,7 +31,7 @@
31
counter = counter+1;
32
end
33
34
-if counter > floor(log(array_length))+1
+if counter > floor(log2(array_length))+1
35
disp('target is not found in aray')
36
37
0 commit comments