Skip to content
Advertisement

Tag: big-o

What is the Big O complexity of this algorithm

I can’t seem to figure out the time complexity for this algorithm. I know that the while loop will execute at O(log n) times because n keeps halving. But I’m not super sure how to represent the time complexity of the inner for loop. Answer Each while loop divides n by 2. Therefore, the first for loop would run n

Kotlin single equal sign “=” object assignment time complexity

What is the time complexity of object assignment using the equals sign in Kotlin (or Java)? More specifically if I have my own object ListNode What would be the copy time below? I find myself often doing this assignment since ListNode passes as val, and I can’t do Answer The assignment does not make a new ListNode object that contains

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

Like the Big O notation “O(1)” can describe following code: 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)? Answer Classic example: This will be: 2k = x → Applying log to both sides → k = log(x)

Advertisement