Python3 program for the above approach
def pairedElements ( arr , sum ) : NEW_LINE INDENT low = 0 ; NEW_LINE high = len ( arr ) - 1 ; NEW_LINE while ( low < high ) : NEW_LINE INDENT if ( arr [ low ] + arr [ high ] == sum ) : NEW_LINE INDENT print ( " The ▁ pair ▁ is ▁ : ▁ ( " , arr [ low ] , " , ▁ " , arr [ high ] , " ) " ) ; NEW_LINE DEDENT if ( arr [ low ] + arr [ high ] > sum ) : NEW_LINE INDENT high -= 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT low += 1 ; NEW_LINE DEDENT DEDENT DEDENT