TransWikia.com

What is Big O of a loop with square root inside?

Computer Science Asked by Lukasz Dynowski on October 21, 2021

Knowing that O(n^2) > O(nlogn) > O(n) > O(sqrt(n)) > O(logn) > O(1) and having below python code:

import math

def f1(n=9):
    return math.sqrt(n)

def f2(n=10):
    return [math.sqrt(i) for i in range(n)]
  • Am I correct to infer that O(f1(n)) = O(1)
  • Am I correct to infer that O(f1(n)) = O(n)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP