Given a string contains only a and b where a comes M times and b comes N times in the string.
I need to compute all the permutation of the string starting with a. What is the most efficient way? Can we use properties of binary numbers ?
Given a string contains only a and b where a comes M times and b comes N times in the string.
I need to compute all the permutation of the string starting with a. What is the most efficient way? Can we use properties of binary numbers ?
Copyright © 2021 JogjaFile Inc.
We start with $a$ so we have $M-1$ times $a$ and $N$ times $b$.
$$\dfrac {(M+N-1)!}{(M-1)!(N!)} $$
Note: $(M+N-1)!$ is all possible permutation since permutation of $a's$ in itself does not change the "word" we divides $(M-1)!$ and with same reasoning we divides $N!$.