I have an iteration algorithm, where at each iteration the amount of computation decrease gradually. Here is an illustration of my algorithm:
Input size: n and Total iteration = k
iter 1: time taken -> f1 * n
iter 2: time taken -> f2 * n
iter 3: time taken -> f3 * n
...
iter k: time taken -> fk * n
where f1 > f2 > f3 >...> fk and 0 <= f1, f2,...,fk <= 1
Question: What is the time complexity of this algorithm? is it Big-O(klog n)
Update:
I think the question seems vague. I’ll explain it in words:
Input for my algorithm is n and I’ll run it over k iterations. but on each iteration the input size reduces by a factor which is unknown. there is no pattern in the reduction.
eg :
iter 1: input size = n (always n)
iter 2: input size = n/2 (can change)
iter 3: input size = n/5 (can change)
iter 4: input size = n/8 (can change)
...
iter k: input size = n/10 (can change)
EDIT
More specifically:
If the denominators of your example:
are strictly integers, then it is O(n*log k ).
Here’s why. For a sequence Xn to be O(Yn), there must exists some M, a real number, and m, an integer, such that Xn < M*|Yn| for all n > m.
Now consider the sequence K = {1, 1/2, 1/3, … 1/k}. Also consider the sequence N = {1, 2, 3, 4…}.
Now let’s let Yn = N^t * K (that’s the outer left product of N and K). This sequence Yn is always greater than your sequence, regardless of the values of the fi’s.
So Xn < 1 * |Yn|, where Yn is the harmonic series times n. As amit pointed out, Yn falls into O(n*log k), so Xn does also. Since we couldn’t have bounded Xn any closer above, our best limiting approximation for Xn is also O(n*log k).