Tracing
Trace the following program. Show the trace and the fi nal output. What do you think the method does?
public class Testmys{ public static void main(String[] args) { int a[] = {1, 0, 0, 1, 0}; System.out.println(mystery(a, 5)); } public static int mystery(int a[], int size) { if (size = = 0) return 0; else if (a[size − 1] = = 0) return 2 * mystery(a, size − 1); else return 2 * mystery(a, size − 1) + 1; }}
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.