educative.io

Educative

Why log2(n) is not multiplied when calculating number of executions for inner loop statements?

Challenge 3 Solution Review: Big O of Nested Loop with Multiplication
Why log2(n) is not multiplied when calculating number of executions for the following statements?

  • j<var;
  • j++
  • sum++

Although in the challenge number 4, you have multiplied log3(n) with the inner loop statements. I don’t understand the reason behind it. Can you please explain or correct solution 3?

3 Likes

Even I have the same doubt

I think it should be NLogN, could author verify it?

1 Like

Although in the challenge number 4, you have multiplied log3(n) with the inner loop statements. I don’t understand the reason behind it. Can you please explain or correct solution 3?
I think they follow this math:

Could you please tell me the source of this formula ? any link ? Thanks

I have the same doubt. Any feedback from the instructor?

I also came up to conclusion that this code runs with nlogn complexity, and I see no answer from an author… this is the first sign of a bad course.