subject
Computers and Technology, 02.08.2021 21:20 kezin

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, then 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-1] == val) {
return getNumberEqual(x, n-1, val) + 1;
}
else {
return getNumberEqual(x, n-1, val);
} // end if
} // end if
} // end getNumberEqual

Required:
Demonstrate that this method is recursive by listing the criteria of a recursive solution and stating how the method meets each criterion.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
Assume that you have an array of integers named a. which of these code segments print the same results? int i = 1; while(i < a.length) { system.out.println(a[i]); i++; } int i; for (i = 0; i < a.length; i++) { system.out.println(a[i]); } for (int i : a) { system.out.println(i); } i and ii only ii and iii only i and iii only all three print the same results. all three print different results.
Answers: 3
question
Computers and Technology, 22.06.2019 02:00
The word ‘play’ comes with many different interpretations and a variety of definitions. discuss some of the various meanings tied to the word play. why is the concept of play thought to be an important addition to the workplace? do some (brief) research online and give an example of how play in the workplace is being done right.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
In which job role will you be creating e-papers, newsletters and preiodicals
Answers: 1
You know the right answer?
The following recursive method getNumberEqual searches the array x of n integers for occurrences of...
Questions