Search By Label
def add_items(n): return n + n + n print add_items(10)
The O(N^2) time complexity means that the running time of an algorithm grows quadratically with the size of the input. It often involves nested loops, where each element in the input is compared with every other element.
def print_items(n): for i in range(n): for j in range(n): print(i,j) print_items(10)
def print_items(n): for i in range(n): for j in range(n): print(i,j) for k in range(n): print(k) print_items(10)
O(n)
for the simple search. It's a guarantee that the simple search will never be slower than O(n) time. In a code where the worst scenario is go thought all the elements the notation is O(n)
def print_items(n): for i in range(n): print(i) print_items(10)