What is the time complexity of the following Python code snippet? Python def…

PYQ Deloitte Hiring Assessment 2024

What is the time complexity of the following Python code snippet?

Python

def find_element(arr, x):

for element in arr:

if element == x:

return True

return False

  1. A.

    O(log n)

  2. B.

    O(1)

  3. C.

    O(n)

  4. D.

    O(n^2)

Attempted by 313 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…