Binary search algorithm with recursive and iterative implementation