I need help coming up with the running time, T(n) for this algorithm
1) for i = 0 to length[A] – 1
2) k = i + 1
3) for j = i + 2 to length[A]
4) if A[k] > A[j]
5) k = j
6) if k ≠ i + 1
7) temp = A[i + 1]
8) A[i + 1] = A[k]
9) A[k] = temp
length[A]=n
I know that line 1 executes n+1 times
and line 2 executes n times
however i'm a little confused about the second for statement, the one in line 3
and how to calculate the 'if' statements
any help is appreciated, thanks