Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function binSearch(A,l,n,x)
- m = l+math.floor((n-l)/2)
- if A[m] == x then
- return m
- elseif n-l < 1 then
- return false
- else
- tmp1 = binSearch(A,l,m,x)
- if not tmp1 == false then
- return tmp1
- end
- tmp2 = binSearch(A,m+1,n,x)
- if not tmp2 == false then
- return tmp2
- end
- end
- end
Add Comment
Please, Sign In to add comment