See, Double parameter recursion works like any other parameterized recursion. More parameters are just some more/extra information for you to evaluate the result.
What you want to achieve with it is up to you.
So let's understand thispascalValue(i, j)
function in breif.
let's look at the last return statement in the function
return pascalValue(i - 1, j - 1) + pascalValue(i - 1, j);
So pascalValues(i, j)
function is being called twice as:
pascalValue(i - 1, j - 1)
pascalValue(i - 1, j)
Now here are the base conditions:
if (j == 0) {
return 1;
}
else if (j == i) {
return 1;
}
Base conditions are nothing but telling the function where to stop, otherwise, the recursive calls will keep on happening and eventually stack will overflow.
So when the base condition is reached, specified value is returned to its previous invocation and result is computed based on the expression which in our case is addition of pascalValue(i - 1, j - 1)
and pascalValue(i - 1, j)
Remember each call will meet its base condition, so if pascalValue(i - 1, j - 1)
reaches its base condition, specified value will be returned which is the result of previous invocation and this result will be combined(because in our case we are adding the result) with the other pascalValue(i, j)
invocation i.e. pascalValue(i - 1, j)
with the then i, j values.
And this will keep on happening until all the invocations are computed and a result is returned.
Look at this SO answer on recursion for better understanding.