Here is the ideone link to my code : http://ideone.com/TdjqlG
What I'm doing is that I'm passing the last bit visited as a parameter and based on whether the bit is 0 or 1 ,doing 2 separate sets of recursive calls. I'm assuming that instead of n element array, the array is of n+1 elements and the (n+1)the element is always 0. Please help!