#t542. 二分查找模版
二分查找模版
Binary Search Template
Problem Description
Given a sorted strictly-increasing array (no duplicate elements), use binary search to find the position of the value . If is not in the array, output -1.
Input Format
The first line contains an integer , the number of array elements ().
The second line contains numbers, the strictly-increasing array elements ( element value ).
The third line contains an integer , the number to search for ().
Output Format
The (1-based) position of in the array, or .
Sample Input 1
10
1 3 5 7 9 11 13 15 17 19
3
Sample Output 1
2
Hint
Try to implement binary search both recursively and iteratively.