Question
Write in Java, a recursive method countBinaryStrings() that has one integer parameter n and returns the number of binary strings of length n that do
Write in Java, a recursive method countBinaryStrings() that has one integer parameter n and returns the number of binary strings of length n that do not have two consecutive 0s. For example, for n = 4, the number of binary strings of length 4 that do not contain two consecutive 0s is 8: 1111, 1110, 1101, 1011, 1010, 0111, 0110, 0101. For this problem, your method needs to return only the number of such strings, not the strings themselves. You may assume that the integer specified in the parameter is positive. The method should be static and embedded in a class called Recursion. This class should also have a main method. In this case, we will call the main method with an argument, the number of bits n. This argument will be in args[0]. You should convert it to an int using the Integer.parseInt method. Look this method up in the Java documentation to see what it does.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started