Skip to content
Advertisement

Big O – O(log(n)) code example

Like the Big O notation “O(1)” can describe following code:

JavaScript
  • What code can O(log(n)) describe?

Another question:

  • What solutions are there for “Big O problems” (what to do, when getting a lot of data as an input)?

Advertisement

Answer

Classic example:

JavaScript

This will be:

JavaScript

2k = x → Applying log to both sides → k = log(x)

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement