I know that there is another topic about this question. But my question is ore specific to a certain algorithm that I wrote and I'd like to know more about it's complexity (since I am not good in this subject).
Here is my algorithm with inputs $a$, which is an integer and $n$, which is an odd natural. And right after that come my thoughts about it: Is $\mathcal{O}(n)$ the time complexity of this algorithm?
My thoughts:
The if-cases in the lines $1$ up to $20$ and $32$ up to $37$ are checked in $\mathcal{O}(1)$.
In lines $21$ and $22$, the symbol is reduced. My guess it that this can happen at most $n$ times, so this would be $\mathcal{O}(n)$.
The remaining if-case in line $24$ divided the number $a$ by $2$ as often as possible. This is done in $\mathcal{O}(\log_2(n))$ times.
So since $\mathcal{O}(n)$ is the dominating term here, I suppose that this is the time complexity of this algorithm.
Are my thoughts correct and is $\mathcal{O}(n)$ the time complexity?