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?

1 Like

Even I have the same doubt

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

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: