This loop keeps running until the array's length reaches 6. Calculate the time complexity.
def loop_until_six(arr): while len(arr) > 6: arr = arr[:len(arr)//3] return arr
The difference between this algorithm and Problem 12 is that the loop stops more pre-maturely. But if the input is in the thousands, whether the loop stops at 6 or 1 is insignificant. The time complexity is still logarithmic.
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.