template<typename T>bool binary_search(T* A, T key, const int length){ int middle = length/2; while (key != A[middle] && middle > 0 && middle < length - 1) { if(key > A[middle]) { middle = (middle + length)/2; } else middle = middle/2; } if(middle ==0 || middle == length - 1) return key == A[middle]; return true;}