How to Swap two numbers without using third variable? Bit Manipulation Interview - XOR
Автор: Firmware
Загружено: 2021-11-13
Просмотров: 993
In this video, we look into an XOR property that helps us swap two numbers using bit manipulations without requiring a third variable in C/C++. This is a commonly asked interview question for software/firmware /embedded roles.
There are other methods available to do the same, such as a combination of multiplication - division, or addition-subtraction. But these methods have a disadvantage against using XOR. For using addition or multiplication, we would have to limit the range of input, else the resultants could go out of range.
Also, a helpful insight that we find through this problem is the associative property and commutative property of XOR operations.
Must know concepts of XOR: • Must know concepts of XOR - Bit Manipulat...
Bit Manipulation basic techniques: • Bit Manipulation - Three most used functio...
See Bit Manipulation Interview Preparation Series here:
• Bit Manipulation Interview Series
#XOR #BitManipulation #BitAlgorithm
You may follow us on Facebook and Instagram:
Facebook : / firmwarecode
Instagram : / firmwarecode
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: