Ternary String - finding recurrence relation

79 Views Asked by At

A. Find a recurrence relation for the number of ternary strings of length n that contain two consecutive 2s.

B. Use this recurrence relation to compute the number of ternary strings of length 5 that contains two consecutive 2s(not 0s or 1s).

How do I go about and solve this problem step by step as I don't have any idea on how to start it.