This function will be called recursively to generate the next bit for given binary string according to its current state
static void generateBinStr ( int [ ] str , int len , int currlen , int occur , int nextbit ) {