From ae71321a8909ca61e9800b0e0a97d8210788fb50 Mon Sep 17 00:00:00 2001 From: Aditi Gupta Date: Sat, 2 Mar 2024 15:43:59 +0530 Subject: [PATCH] Update README.md --- Algorithms/Utils/Swap/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Algorithms/Utils/Swap/README.md b/Algorithms/Utils/Swap/README.md index 6c419b3..50d51dd 100644 --- a/Algorithms/Utils/Swap/README.md +++ b/Algorithms/Utils/Swap/README.md @@ -31,3 +31,11 @@ The swap algorithm takes 2 variables, and swap the values of them so that finall ## Tips - Use `SwapNum` for keeping memory footprint to minimum. +## Swap number using Bitwise XOR Operator + +function swapByXOR(a,b): + a = a ^ b # set bits, either set in a or b, store it in a + b = a ^ b # set bits which were set in original a, store it in b + a = a ^ b # set bits which were set in original b, store it in a + +