Discrete: Recurrence relation for sum of integer using only 2's and 3's.

In summary, the conversation discusses finding a recurrence relation for Tn, which represents the number of ways to write an integer n as the sum of terms, each of which is 2 or 3, and where order matters. The attempted solution involves mapping out smaller values of n and noticing a pattern, but ultimately realizing that the recurrence relation is dependent on f(n-2) and f(n-3), where adding a 2 or 3 to the previous sum produces all possible combinations. The conversation concludes with the offer of further assistance if needed.
  • #1
praecox
17
0

Homework Statement


Find a recurrence relation for Tn, the number of ways to write an integer n as the sum of terms, each of which is 2 or 3, and the order matters. [So 2+3 and 3+2 are different sums for 5.]

Homework Equations



(if I had one, this would be easier)

The Attempt at a Solution


So I tried at first to just map out some of the smaller n's:
T0=0
T1=0
T2=1
T3=1
T4=2 (2+2) & (2'+2)
T5=2 (as above)

A nice pattern seemed to emerge for a moment, but then it fell apart:
T6 had (2+2'+2'') and it's permutations (3!=6) and (3+3') and it's 2 permutations. So T6=8.
But T7 only has (2+2'+3) and it's 6 permutations, so T7=6.

I'm thinking that f(n) is probably dependent on f(n/3) or f(n/2), or both. I don't think it's going to be a simple f(n) based on f(n-1)... but I could be wrong.

It seems like when finding recurrence relations you just have to have an aha! moment - and I'm not having one on this. Any help would be awesome!

FYI: I'm using 2' and 2'' just to keep track of the permutations, since order matters, just to help me remember that (2+2')≠(2'+2).

EDIT: I misunderstood the problem. The permutations of 2's and 3's, like in the above sums of 5, have order matter. But for 2+2+2...+2, order does not matter. So I think I actually have it now:

T0=0
T1=0
T2=1
T3=1
T4=1 (2+2)
T5=2 (as above)
etc...

So for n>3, f(n)=f(n-2)+f(n-3).
 
Last edited:
Physics news on Phys.org
  • #2


This recurrence relation works because to get to Tn, you can either add a 2 to the previous sum (giving you Tn-2) or add a 3 to the previous sum (giving you Tn-3). This covers all possible ways to get to Tn, and since order matters, you have to consider all possible combinations of adding 2's and 3's.

Hope this helps! Let me know if you have any further questions.
 

FAQ: Discrete: Recurrence relation for sum of integer using only 2's and 3's.

What is a recurrence relation?

A recurrence relation is an equation or formula that is used to define a sequence of numbers, where each term in the sequence is a function of one or more of the previous terms.

How is a recurrence relation used to solve the sum of integers using only 2's and 3's?

The recurrence relation for the sum of integers using only 2's and 3's is defined as follows: f(n) = f(n-2) + f(n-3) with the base cases f(0) = 0, f(1) = 0, and f(2) = 1. This means that the sum of integers can be calculated by adding the previous two terms in the sequence, starting with f(2) = 1. By using this recurrence relation, we can efficiently calculate the sum of integers using only 2's and 3's without having to manually add each term.

What is the time complexity of using a recurrence relation to solve this problem?

The time complexity of using a recurrence relation to solve the sum of integers using only 2's and 3's is O(n), where n is the number of terms in the sequence. This means that the time it takes to calculate the sum grows linearly with the number of terms in the sequence.

Can the recurrence relation be modified to solve the sum of integers using other numbers?

Yes, the recurrence relation can be modified to solve the sum of integers using any set of numbers. The key is to define the recurrence relation in terms of the previous terms in the sequence, and to specify the base cases accordingly.

Are there any limitations to using a recurrence relation to solve this problem?

The recurrence relation for the sum of integers using only 2's and 3's assumes that the input n is a positive integer. Additionally, as n grows larger, the numbers in the sequence can become very large, which may cause computational issues. However, for smaller values of n, a recurrence relation is an efficient and effective way to solve this problem.

Back
Top