human
Generate all binary strings without consecutive 1 's | A utility function generate all string without consecutive 1 'sof size K.
print binary string without consecutive 1 's.
terminate binary string.
if previous character is '1' then we put only 0 at end of string example str = "01" then new string be "000".
if previous character is '0' than we put both '1' and '0' at end of string example str = "00" then new string "001" and "000".
function generate all binary string without consecutive 1 's.
Base case.
One by one stores every binary string of length K.
Generate all Binary string starts with '0.
Generate all Binary string starts with '1.
Driver code"
Solution in Python:
 ... Write me a code to generate all binary strings without consecutive 1 's and the other steps required?
assistant
#Here is code to generate all binary strings without consecutive 1 's and the other steps required.
 def generateAllStringsUtil ( K , str , n ) :
	if ( n == K ) :
		print ( * str [ : n ] , sep = " " , end = " ▁ " )
		return
	if ( str [ n - 1 ] == '1' ) :
		str [ n ] = '0'
		generateAllStringsUtil ( K , str , n + 1 )
	if ( str [ n - 1 ] == '0' ) :
		str [ n ] = '0'
		generateAllStringsUtil ( K , str , n + 1 )
		str [ n ] = '1'
		generateAllStringsUtil ( K , str , n + 1 )
def generateAllStrings ( K ) :
	if ( K <= 0 ) :
		return
	str = [ 0 ] * K
'
	str [ 0 ] = '0'
	generateAllStringsUtil ( K , str , 1 )
'
	str [ 0 ] = '1'
	generateAllStringsUtil ( K , str , 1 )
K = 3
generateAllStrings ( K )