0

I was wonder what the time complexity of certain operation in python are:

x = k * l ( multiplication )

x = k/l ( division )

math.sqrt(y)

math.pow(y,f)

and what is the complexity for using a while - loop.

1 Answer 1

4

I truly believe it's the same in Python as in every other common languages?

x = k * l # multiplication  -> O(n²)

x = k/l # division -> O(n²)

math.sqrt(y) # -> O(M(n))

math.pow(y,f) # -> O(M(n))k), n digits number and k bit exponent 

while loop # -> O(n) ,same as For loop.

Edit : For multiplication, Python uses the standard multiplication algorithm O(n²) but for very big numbers, it goes with Karatsuba algorithm, so O(n^1.585) according to wikipedia.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.