The number of balanced parenthesis sequences can also be counted with the formula
n/2+11(n/2n).
Here (ba) is a binomial coefficient that can be computed with the formula
b!(a−b)!a!.
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: