I designed an algorithm like this but I do not know how to perform its analysis to determine how it runs $($$O(n)$, $O(n^2)$, $O(log(n)$, $etc$$)$
m = some constant
for i = 1 to n
{
for j = 1 to m step 2
{
// do some stuff here
}
m = m - 2
}
Can you please provide a clue to solve my issue? This is a homework and I only have to deliver the algorithm, but I want to go farther and determine its behavior. I have analyzed other (maybe simpler) algorithms but this is kind of different of what I have seen.
Respectfully,
Jorge Maldonado
m=some constant/2 ... for j=1 to m { ... } m=m-1
. – David Richerby Sep 23 '16 at 15:37m
in iteration $i$ is $m_i = M - 2(i-1)$ with $M$ the initial value ofm
. – Raphael Sep 23 '16 at 15:47