I am trying to learn time complexities. I have come across a problem that is confusing me. I need help to understand this:
my_func takes an array input of size n. It runs three for loops. In the third loop it calls for another function that is O(1) time.
def my_func(A):
for (int i=1; i<n; i++)
for (int j=1; j<i; j++)
for (int k=1; k<j; k++)
some_other_func();
My Questions:
- Am I right if I say that total number of steps performed by my_func() is O(n^3) because:
- the first for loop goes from 1 to n-1
- the second for loop goes from 1 to n-2
- the third loop goes from 1 to n-3
- What is asymptotic run time and what is the asymptotic run time for the above algorithm?
- What is the meaning of the following:
