The following recursive method getNumberEqual searches the array x of n integers for occurrences of the integer val. It returns the number of integers in x that are equal to val. For example, if x contains the 9 integers 1, 2, 4, 4, 5, 6, 7, 8, and 9, dien getNumberEqual (x, 9, 4) returns the value 2 because 4 occurs twice in x.
public static int getNumberEqual(int x[], int n, int val){
if (n ⇐ 0) {
return 0;
}
else {
if (x[n-l] == val) {
return getNumberEqual(x, n-1, val) + 1;
}
else {
return getNumberEqual(x, n-1, val);
} // end if
} // end if
} // end getNumberEqual
Demonstrate that this method is recursive by listing the criteria of a recursive solution and stating how the method meets each criterion.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.