added algorithm to compute the next/prev int that has same number of 1s set