Computer Science, asked by kavyabadiroyal, 6 months ago

What is the time complexity of the following function!
function finde lement(array, target)
for (var i = 0; i < array.length; i++)
if (array[i] ---target)
return array[i];
return null;​

Answers

Answered by llchummill
6

Answer:

1) O(1): Time complexity of a function (or set of statements) is considered as O(1) if it doesn't contain loop, recursion and call to any other non-constant time function. For example swap() function has O(1) time complexity. A loop or recursion that runs a constant number of times is also considered as O(1).

Similar questions