I'm preparing for an exam, and I ran across the following algorithm:
for(int j = 1 to n) {
k=2
while (k < n) {
sum+= a[k] * b[k]
k+= log(k)
}
}
I'm trying to work on finding the complexity of the algorithm. Here's what I have so far.
The outside loop obviously runs in n steps. The inside loop gets incremented by log(k), so it should run faster than n as log(n) when n >= 2 is greater than 1. Overall, it looks like the overall complexity is a little faster O(n^2), but by how much? I guess the question boils down to: How do I find the complexity of the inner loop when it is incremented by a function of k? What is the final complexity in this case? I'm assuming O(n^2) is technically correct since it will still be an upper bound, but is there a more accurate answer here?