Swap Algorithm
A = A + B
B = A - B
A = A - B
You can not use this approach as while adding A & B (A + B), it could result in a "OVERFLOW"
Hence, we use this approach
X := X XOR Y
Y := X XOR Y
X := X XOR Y
A = A + B
B = A - B
A = A - B
You can not use this approach as while adding A & B (A + B), it could result in a "OVERFLOW"
Hence, we use this approach
X := X XOR Y
Y := X XOR Y
X := X XOR Y
No comments:
Post a Comment