Calculating steps required for each element to reach its sorted position
for i in range ( 1 , n + 1 ) : NEW_LINE INDENT c = 1 NEW_LINE j = dat [ i ] NEW_LINE while ( j != i ) : NEW_LINE INDENT c += 1 NEW_LINE j = dat [ j ] NEW_LINE DEDENT b [ i ] = c NEW_LINE DEDENT