Answer the question
In order to leave comments, you need to log in
Is the efficiency of this algorithm O(n*log(n))?
I am writing one code, I need to find out the time efficiency. I'm guessing O(n*log(n)), but I'm not sure.
Here is the code:
int end = 10;
void task1()
{
for (int i = 0; i < (int)(end/ 2); i++)
{
// код 1
}
}
void mainTask()
{
task1();
while(end != 0)
{
task1();
end--;
}
}
mainTask();
Answer the question
In order to leave comments, you need to log in
It looks like O(1) if O(1) happens inside the loop, because there is no changeable parameter from which the
UPD time would change
if end is a variable, then it will be O(N^2)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question