> I fixed the issue i.e. now log(x) term is being included in big O notation but I'm facing another problem.

I don't see you do this.  Thus, I can't help.