Analyzing parallel performance question
Suppose that the fraction of foo() that is parallelizable is $\alpha$. Then the total execution time with $n$ cores is:

the non-parallelizable execution, done by only one core: $(1- \alpha)\times 20$
the parallelizable execution: $\alpha \times 20 \times \frac{1}{n}$

Then, for the first question, we have to consider that the number of cores is $3$, and the total time is $10$. The equation becomes:
$(1-\alpha)\times 20 + \alpha\times \frac{20}{3} = 10\Leftrightarrow \alpha = 0.75$.
For the second question, we suppose known the answer to the first question: $\alpha = 0.75$, and we suppose then that $n = \infty$. The total execution time becomes:
$0.25 \times 20 + 0.75\times \frac{20}{\infty} = 0.25 \times 20 = 5$.