Question: The main objective of this lab is to implement Java programs and algorithms using recursion. Exercise 1 ( 1 0 marks ) Implement a recursive
The main objective of this lab is to implement Java programs and algorithms using recursion.
Exercise marks
Implement a recursive function to count the number of zeros in a number.
Note:
Example: has zeros
If n has two or more digits
the number of zeros is the number of zeros in with the last digit removed
plus an additional if the last digit is zero
Examples:
number of zeros in is number of zeros in plus
number of zeros in is number of zeros in plus
numberOfZeros in the number N
number of digits in N
Decomposition:
numberOfZeros in the first digits
Last digit
Composition:
Add:
numberOfZeros in the first K digits
if the last digit is zero
Base case:
has one digit
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
