This loop keeps running until the array's length reaches 1. Calculate the time complexity.
def loop_until_one(arr): while len(arr) > 1: arr = arr[:len(arr)//3] ## divides array by 3
How does the running time increase w.r.t the input?
The running time's rate of increase is . The number of steps reflects how many times the input size can be divided by 3.
What is the time complexity?
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.