added the code to perform a revere on alternate k nodes