Runtime of computing the coefficient of a product of multinomials?

62 Views Asked by At

Suppose I have $k$ variables, $ x_1, x_2, ... x_k $ and $m$ expressions in the form $ (1 +$ the product of some subset of $x_1 ... x_k)$ – for instance, $(1 + x_1)$ or $(1 + x_1x_2x_5)$ could be one of the $m$ equations, but not something like $(1 + x_1^2)$. What is the runtime of calculating a coefficient of a term such as $x_1^{10}x_2^{20}$ with the above constraints?

My intuition is that for $m$ expressions, you can end up with $(m+1)^k$ potential combinations of variables, and you can create counters for them. Then, for each expression, you increment the appropriate counters after running the calculations, arriving at a runtime of $ O(m * (m + 1)^k)$ which can be simplified in big-O notation as $O(m^{k+1})$. Does this make sense? Is there a quicker solution for it?