Menu

[solved]-Need 3b Code Public Static Int Countzeroes String Bitstring Bitstring Null Bitstringlength Q39015926

ONLY NEED 3b)

Question 3 (a) Write a recursive algorithm called zeroes that counts the number of Os in a bit string. (b) Prove the correct

a)

CODE

public static int countZeroes(String bitString) {

if (bitString == null || bitString.length() == 0) {

return 0;

}

if (bitString.charAt(0) == ‘0’) {

return 1 + countZeroes(bitString.substring(1));

}

return countZeroes(bitString.substring(1));

}

Question 3 (a) Write a recursive algorithm called zeroes that counts the number of O’s in a bit string. (b) Prove the correctness of your algorithm. Show transcribed image text Question 3 (a) Write a recursive algorithm called zeroes that counts the number of O’s in a bit string. (b) Prove the correctness of your algorithm.

Expert Answer


Answer to ONLY NEED 3b) a) CODE public static int countZeroes(String bitString) { if (bitString == null || bitString.length() == 0… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *