How many non decreasing sequence of length k is possible?

197 Views Asked by At

If we have a set like this { 1A ,2A ,2B, 3A, 3B, 3C}, how many non decreasing sequence is possible, such that number in left is less than number in right of length k? i.e, Length = 2 then the following sequence are possible: 1A 1A, 1A 2A, 1A 2B, 1A 3A, 1A 3B, 1A 3C, 2A 2B, 2B 2A, 2A 3A, ..... 3C 3C in total 25 combinations would be possible.

1

There are 1 best solutions below

0
On

Put X = 1, Y = 2, Z = 3 and compute for a few values of k. E.g. for k = 2, you have

XX = 1, XY = 2, XZ = 3, YY = 4, YZ = 6, ZZ = 9, giving your total of 25

Similarly, for k = 3, compute XXX, XXY, XXZ, XYY, XYZ, XZZ, YYY, YYZ,YZZ & ZZZ, and sum up.

Discern commonality between successive values of k, and work out through recursion.

You will get $f_n = 3f_{n-1} - 2f_{n-2} + 3^n$,

with $f_0 = 1, f_1 = 6$ as initial values