This function returns
True if it finds an element, and
def find_item(arr, element): for i in range(len(array)): if arr[i] == item: return True return False
We're only interested in the upper bound. We can expect the following runtime if the loop never finds the element.
How does the runtime increase w.r.t. input size?
The number of steps is determined by the size of the array: .
What is the time complexity?
: the runtime increases linearly with the input size.
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.