Consider the routine below checks whether the input myArray
contains three elements, a
, b
, and c
such that a + b = c
. Determine the run-time complexity of the routine using Big-O notation.
def check_for_sum_triplet(myArray):
for element_a in myArray:
for element_b in myArray:
for element_c in myArray:
if element_a + element_b == element_c:
return TRUE
return FALSE
The algorithm as written above has a run-time complexity of
Box 1: Select the best answer