This loop runs
n * 5 times. What is the time complexity?
def increment_by(n): result = 0 for i in range(n * 5): result += 1 return result
How does the runtime increase w.r.t. input size?
The number of loops is 5 times the input size .
What is the time complexity?
Whether it's , , or , always drop the constant. Never try to be specific. The runtime is proportionately linear to the input size, and it follows that the time complexity is .
This workbook was created by Jad and Rayan Slim. Feel free to explore some of their courses:
The Complete Java Development Bootcamp
The Complete Spring Boot Development Bootcamp – Become a Java Web Developer
There are no written reviews yet.