In the following code that uses recursion to find the greatest common divisor of a number, what is the base case?
```
public static int gcd(int x, int y)
{
if (x % y == 0)
return y;
else
return gcd(y, x % y);
}
```
a. gcd(int x, int y)
b. if (x % y == 0)
return y;
c. else
return gcd(y, x % y);
d. Cannot tell from this code
b. if (x % y == 0)
return y;
You might also like to view...
Hand trace a queue X through the following operations:
``` X.enqueue(new Integer(4)); X.enqueue(new Integer(1)); Object Y = X.dequeue(); X.enqueue(new Integer(8)); X.enqueue(new Integer(2)); X.enqueue(new Integer(5)); X.enqueue(new Integer(3)); Object Y = X.dequeue(); X.enqueue(new Integer(4)); X.enqueue(new Integer(9)); ```
Your company is merging with a smaller company, and the two networks will be joined. What information should be the first thing identified when developing the interconnection policy?
A. malware packages B. the data types that need to flow between the companies C. the IP addressing D. the encryption protocol
Programs that run within a browser and allow users to view and interact with files within the browser’s window are called _______________.
Fill in the blank(s) with the appropriate word(s).
In the pseudocode for the dfs function for partitioning the vertices in a graph into disjointed components, what is the missing pseudocode statement?
dfs(graph, v, s): mark v as visited s.add(v) for each vertex, w, adjacent to v: if w is unvisited:
A. s.add(w) B. dfs(graph, v, s) C. s.add(v) D. dfs(graph, w, s)