I am having trouble calculating the complexity of this problem:
REVERSE3(A): // Reverse the order of elements in an array // P is an array; assume generating next permutation takes 1 step. for every possible permutation P of A: for index i = 1 to N: if P[i] is not equal to A[N-i+1]: continue to the next permutation // All elements matched in proper places return P
I think some of my misunderstandings arise from the first for-loop. What does it even mean? How would you calculate the complexity for this?
Any help would be appreciated. Thank you.