print the series in Java 11 110 1110
Answers
Answer:
/ java program to print all N-bit binary
import java.io.*;
class GFG {
// function to generate n digit numbers
static void printRec(String number,
int extraOnes,
int remainingPlaces)
{
// if number generated
if (0 == remainingPlaces) {
System.out.print(number + " ");
return;
}
// Append 1 at the current number and
// reduce the remaining places by one
printRec(number + "1", extraOnes + 1,
remainingPlaces - 1);
// If more ones than zeros, append 0 to the
// current number and reduce the remaining
// places by one
if (0 < extraOnes)
printRec(number + "0", extraOnes - 1,
remainingPlaces - 1);
}
static void printNums(int n)
{
String str = "";
printRec(str, 0, n);
}
// Driver code
public static void main(String[] args)
{
int n = 4;
// Function call
printNums(n);
}
}
// This code is contributed by vt_m
if it helped you please mark BRAINLIST。◕‿◕。
Answer:
Which of the following correctly represents the model?
Select one:
11 122 = 1110
1 110 = 1110
1 110 = 1122
1 122 = 1110
Assessment question image
Explanation: