human
Generate all the binary strings of N bits | Function to print the output.
Function to generate all binary strings.
First assign "0" at ith position and try for all other permutations for remaining positions.
And then assign "1" at ith position and try for all other permutations for remaining positions.
Driver Code.
Print all binary strings"
Solution in Python:
assistant
#Here is code to generate all the binary strings of N bits and the other steps required.
 def printTheArray ( arr , n ) :
	for i in range ( 0 , n ) :
		print ( arr [ i ] , end = " ▁ " )
	print ( )
def generateAllBinaryStrings ( n , arr , i ) :
	if i == n :
		printTheArray ( arr , n )
		return
	arr [ i ] = 0
	generateAllBinaryStrings ( n , arr , i + 1 )
	arr [ i ] = 1
	generateAllBinaryStrings ( n , arr , i + 1 )
if __name__ == " _ _ main _ _ " :
	n = 4
	arr = [ None ] * n
	generateAllBinaryStrings ( n , arr , 0 )