Big O
)}

Problem

This function returns True if it finds an element, and False otherwise.

def find_item(arr, element): for i in range(len(array)): if arr[i] == item: return True return False

Solution

We're only interested in the upper bound. We can expect the following runtime if the loop never finds the element.

Input SizeSteps
11
22
33
44
55

How does the runtime increase w.r.t. input size?

The number of steps is determined by the size of the array: NN.

What is the time complexity?

O(N)O(N): 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

Feedback Summary
0.0
0 students
5

0%
4

0%
3

0%
2

0%
1

0%
Written Reviews
There are no written reviews yet.