generalised type instead of Int
binary search + tests