The problem 5.2 is quite simple, it asks for bit swapping, so we need to check if i-th or j-th bit are different, if not no need to swap, if they are then just xor the number with 1 shifted left by i bits and 1 shifted left by j bits. Take a look at the code here.
Categories