Dynamic Programming problem - I really need some help here

My assignment is to create a java program that counts the number of N-lettered words which are composed of the letters A, B, or C. There is a special rule that A cannot be next to C. Note that I'm not looking for real words - just permutations.

So, I have the algorithm down recursively. It's just a program with three methods each representing and appending A, B, or C to a String. For example A calls on A and B but not C - and so on - until the length of the string is the desired length, N. The method then returns the string it was given, prior to appending the letter.

But apparently I'm supposed to use dynamic programming to program it iteratively. I've been banging my head against a wall trying to figure out what I'm supposed to do here.

Anything would help at this point. Help me understand what dynamic programming is. Help my understand this problem. Please and thank you.

Posted Apr 15, 2016, 1:38 AM UTC

21
Loading comments…