Recurrence relations and the empty set

51 Views Asked by At

I am currently setting up my variables and such for solving a problem and I am a bit confused about this little detail.

The question is: How many ways can you make a number using only '1' and '2'?

For example: $$a_3 = 3$$

because to make the number three we can have the following sequences:

{1,1,1}, {1,2} , {2,1}

where order matters.

However, can someone explain to me why $$a_0 = 1$$

It is impossible to make the number '0' with the given numbers one and two, but yet the textbook says that it is? Is this implying that the empty set is always one or is it saying that there is 1 way to make nothing?

1

There are 1 best solutions below

0
On BEST ANSWER

The recurrence relation for your problem is $a_n = a_{n-1} + a_{n-2}$ (so this is actually the Fibonacci sequence shifted by one). This is true since in order to get a sequence summing to $n$, you can take a sequence summing to $n-1$ and add a $1$ to the end, or take a sequence summing to $n-2$ and add a $2$ to the end. We are using here the fact that the sum of a sequence is equal to its last element plus the sum of the sequence obtained by removing the last element. For this definition to hold for singleton sequences, we must fix the sum of the empty sequence at $0$. Similarly, it is often convenient to regard the product of the empty sequence to be $1$. More generally, given an associative operation with identity element $e$, we can define a corresponding "folding" operation, which when applied to the empty sequence should answer $e$.