Let n be a natural number, n >= 3. A ternary string is a sequence of n symbols that has some of the digits 0, 1, 2.

tamolam8

tamolam8

Answered question

2022-09-06

Discrete mathematics - ternary strings.
Let n be a natural number, n≥3. A ternary string is a sequence of n symbols that has some of the digits 0, 1, 2. In other words, a ternary string is a n-permutation with a repetion of the set { 0 , 1 , 2 }. I wonder how to find the number of ternary strings that have at least one 0, one 1 and one 2.
I know that there is a inclusion-exclusion principle, and for that we need to know at least the number of items in the sets, such as A, B and so on.. That being said simply adding the elements in A and B together will show us the elements in the intersection, however we will need to substract the intersection of A and B in order to obtain the number of elements in the union. My confusion is if there is something different by being a ternary string and also by the domain of the sets that has those ternary strings, the mathematical approach I'm thinking of is something like:
A B = A + B A B

Answer & Explanation

Everett Mclaughlin

Everett Mclaughlin

Beginner2022-09-07Added 16 answers

Step 1
Let X be the set of ternary strings of length n with no additional restriction. Let A be the strings of length n with no zeroes. Let B the strings of length n with no ones, and C with no twos.
You are asked to count | A c B c C c | , the number of strings who have at least one zero, at least one one, and at least one two.
This can be rearranged as | ( A B C ) c | = | X | | A B C | which expands via inclusion-exclusion as:
| X | | A | | B | | C | + | A B | + | A C | + | B C | | A B C |
Each of these terms should be easy to calculate.
Step 2
For instance, |A| is the number of ternary strings of length n with no zeroes. Each of the n digits in the string then have two possible options... either a 1 or a 2. There are by rule of product 2 n possible such strings in A.
Plugging everything in and simplifying gives the following expression then:
3 n 3 2 n + 3 1 n 0 n
(Note what happens for n = 0. There does exist one length zero string, the empty string, but it does not satisfy having at least one of each digit, so the expression above correctly simplifies to zero overall. Remember, 00 in combinatorics is equal to 1)
Anabelle Guzman

Anabelle Guzman

Beginner2022-09-08Added 14 answers

Step 1
Using generating functions, the answer is the coefficient of x n in the expansion of
n ! ( x + x 2 2 ! + x 3 3 ! + ) ( x + x 2 2 ! + x 3 3 ! + ) ( x + x 2 2 ! + x 3 3 ! + )
Each series represents choosing a corresponding digit (e.g. the first could represent choosing 0). The coefficients are explained as following: Let's say we pick x a a ! from the first term, x b b ! from the second, and x c c ! from the third such that a + b + c = n. We get that this term is n ! x a x b x c a ! b ! c ! = n ! a ! b ! c ! x n .
The number of orderings such that we have a 0's, b 1's, and c 2's is the multinomial coefficient ( n a , b , c ) = n ! a ! b ! c ! . Hence, we are correctly counting all possible strings.
Step 2
To actually find the coefficient of x n in this expansion, we use the taylor series
e x 1 = k = 1 x k k !
Our generating function becomes
n ! ( e x 1 ) 3
n ! ( e 3 x 3 e 2 x + 3 e x 1 )
Since the coefficient of x n in e k x is k n n ! , so the coefficient of x n is
k = 0 3 ( 3 k ) ( 1 ) k + 1 k n
You might notice the semblance to the formula for the Stirling numbers to the second kind.

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?