I dont know why I am getting confused about this as this is relatively simple but I am going to ask anyway...
Consider the following algorithm: Given a value k, compute ak, and binary search for ak in an array of size N. Consider the fact that multiplication takes O(log2(a)k) time.
What would the total runtime for this algorithm be? Here are my thoughts:
In the worst case, binary search will make log2(N) comparisons, and for each comparison, it takes O(log2(a)k) to calculate ak. So the total would be O(log2(a)k(log2(N)))? Am I going about this the correct way?