Ternary String recursion relation

In summary, the conversation is about finding the recursion relation for consecutive 0s in a ternary string. The solution provided involves equations for strings starting with 1, 2, 01, 02, and 00. The relation is an = 2an-1 + 2an - 2 + 3^n-2 for n >= 3, where n is the length of the string. The number of strings starting with 00 is represented by 3^n-2. The conversation also discusses the reasoning behind the equations and the confusion about the use of n-1 and 3^n-2.
  • #1
DorumonSg
64
0
I don't understand this at all I have the solution but no idea.

I am suppose to find the recursion relation for consecutive 0 in a ternary string(String that contains only 0, 1 and 2)

So the solution I have is :

Strings starting with 1 = an(The n is the small n for recursion) - 1
Strings startring with 2 = an - 1
Strings starting with 01 = an - 2
Strings starting with 02 = an - 2
Strings starting with 00 = 3^n-2

So the relation is an = 2an-1 + 2an - 2 + 3^n-2 for n >= 3

So how did they get the relation?

Why an - 1? What is the length of the String they base their calculations on?

Example :

I take Strings starting with 1, I can have 10, 11, 12, why an - 1? and not an - 3, all 3 do not have consecutive 0s?

Or if I take the length of the String as 3, I can have 100, 110, 101, 102, 111... so why -1? When I have so many other strings to minus off?

And also for 00,

Where did the 3^n come from?

This is so mind confusing.
 
Physics news on Phys.org
  • #2
I think you misunderstand what the equations say. The idea is that we let [itex]a_n[/itex] be the number of ternary strings of length n with 00 as a substring. Now if we have a string of length n starting with 1, then it contains consecutive 0 iff the remaining (n-1) characters do. Thus the number of such strings having consecutive 0s is equal to the number of strings of length (n-1) having consecutive 0s, i.e. [itex]a_{n-1}[/itex] (which you wrote as an-1). Similar reasoning holds for the remaining cases. Note that the number of such strings starting with 00 is:
[tex]3^{n-2}[/tex]
I think you may have interpreted the results as [itex]a_n-1[/itex] and [itex]3^n-2[/itex] which is incorrect.
 
  • #3
rasmhop said:
I think you misunderstand what the equations say. The idea is that we let [itex]a_n[/itex] be the number of ternary strings of length n with 00 as a substring. Now if we have a string of length n starting with 1, then it contains consecutive 0 iff the remaining (n-1) characters do. Thus the number of such strings having consecutive 0s is equal to the number of strings of length (n-1) having consecutive 0s, i.e. [itex]a_{n-1}[/itex] (which you wrote as an-1). Similar reasoning holds for the remaining cases. Note that the number of such strings starting with 00 is:
[tex]3^{n-2}[/tex]
I think you may have interpreted the results as [itex]a_n-1[/itex] and [itex]3^n-2[/itex] which is incorrect.

Hey wait... even if you say that n - 1 is because iff the consective string is 00... but what if the consecutive string is not 00? it doesn't take that into account?

Okie, but I don't understand why is it for 00 it is [tex]3^{n-2}[/tex]
 
Last edited:
  • #4
DorumonSg said:
Hey wait... even if you say that n - 1 is because iff the consective string is 00... but what if the consecutive string is not 00? it doesn't take that into account?
I'm not sure exactly what you mean here. Could you elaborate? We are always looking for consequtive 0s (i.e. for 00).

Okie, but I don't understand why is it for 00 it is [tex]3^{n-2}[/tex]

[itex]3^{n-2}[/itex] is the number of ternary strings of length (n-2). If we know the string starts with 00 we just want the last (n-2) characters to be arbitrary.
 

What is a Ternary String recursion relation?

A Ternary String recursion relation is a mathematical concept that involves defining a sequence of strings where each string is composed of three symbols, and the next string is obtained by applying a set of rules or operations to the previous string. This process is repeated recursively, creating a sequence of strings that are related to each other.

How is a Ternary String recursion relation solved?

A Ternary String recursion relation is typically solved by using a recursive algorithm or by converting it into a closed form equation. The recursive algorithm involves breaking down the relation into smaller subproblems and solving them one by one until the solution for the original problem is obtained. The closed form equation uses a formula to directly calculate the nth term of the sequence without having to solve each subproblem.

What are some real-world applications of Ternary String recursion relation?

Ternary String recursion relation has various applications in computer science, such as in the design and analysis of algorithms, coding theory, and data compression. It is also used in biology to model the growth of certain organisms and in linguistics to study the structure of languages.

What are the limitations of Ternary String recursion relation?

One of the limitations of Ternary String recursion relation is that it can only be applied to certain types of problems. In some cases, the recursive algorithm can also be inefficient and may require a lot of memory and processing time to solve the problem. Additionally, the closed form equation may not always exist for a given recursion relation, making it difficult to find a direct solution.

How is Ternary String recursion relation different from other types of recursion relations?

Ternary String recursion relation is different from other types of recursion relations in that it involves strings composed of three symbols, whereas other types may involve numbers, characters, or other objects. It also has its own set of rules and operations that are specific to ternary strings. However, the basic concept of breaking down a problem into smaller subproblems and solving them recursively remains the same.

Similar threads

  • Calculus and Beyond Homework Help
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
940
  • Calculus and Beyond Homework Help
Replies
1
Views
909
  • General Math
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
3K
  • Programming and Computer Science
Replies
1
Views
871
  • Beyond the Standard Models
Replies
31
Views
2K
Back
Top