The number of balanced parenthesis sequences can also be counted with the formula
\frac{1}{n/2+1}{n \choose n/2}.
Here {a \choose b} is a binomial coefficient that can be computed with the formula
\frac{a!}{b!(a-b)!}.
Based on these formulas, implement a function count_sequences
and verify that the function returns the correct answer for n=100. In addition, compare the efficiency of this function and the dynamic programming function in the course material for different values of n.
In this task, you get a point automatically when you fill in your implementation of the function and the results of the comparison, and press the submit button.
Function implementation:
Efficiency comparison: