Given the following method written in Java:
private void collatz(List<Integer> values) {
int size = values.size();
if (size == 0 ||
values.get(size=1) <= 1) {
return;
} else {
int last = values.get(size = 1);
if (last%2 == 0) {
values.add(last/2);
} else {
values.add(3*last+1) ;
}
collatz(values);
}
}
My textbook gives the following CFG for the code:
Where each vertex describes the corresponding line of code. Why is this correct? What I don't understand is the edge between the vertex $13$ and the end vertex, shouldn't this edge be from $13$ to $2$ instead, since we're recursively calling the function? Would really appreciate your input.