Binary Search Algorithm in Python: Iterative & Recursive Implementation
Given a sorted array of integers `nums` and an integer `target`, write a function to search for `target` in `nums`. If `target` exists, return its index. Otherwise, return `-1`. The algorithm must run with O(log n) runtime complexity.