Big O
)}

Problem

This function returns the first item in an array.

def first_item(arr): return arr[0]

Solution

Input SizeLoops
11
21
31
41
51

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

It does not.

What is the time complexity?

O(1)O(1): indexing an array is a constant time operation.


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.