Padovan String, C/C++ Programming

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the characters ‘X’ , ‘Y’ and ‘Z’ only, and given value of n, write a program that counts the number of occurrences of the string in the n-th Padovan string P(n). An example is given below. For n = 6 and the string ZY, the program should count the occurrences of ZY in P(6). P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 P(3) = P(1)+P(0) P(3) = YX P(4) = P(2)+P(1) P(4) = ZY P(5) = P(3)+P(2) P(5) = YXZ P(6) = P(4)+P(3) P(6) = ZYYX
Posted Date: 9/1/2012 2:55:06 AM | Location : United States







Related Discussions:- Padovan String, Assignment Help, Ask Question on Padovan String, Get Answer, Expert's Help, Padovan String Discussions

Write discussion on Padovan String
Your posts are moderated
Related Questions
padovan series with words

No. it's not required The C++ language guarantees that delete p will do nothing if p is equivalent to NULL. As you might get the test backwards, and as most testing methodologie

Build a program that calculates a discount for items based on quantity bought each item is $99.99 Ask user to enter the quantity of the items Get the quantity of items from the u


define a class for student

A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to execute an implied conversion of types. Its purpose is reserved ex

Write a Program that illustrate creation of a data file? Here is a program to generate a Fibonacci series and write it into a Data file. # include main() { FILE *fpt;

write an algorithm for linear search algorithm

Write a function that takes an array as the argument and returns the second largest element. Bonus (+5): Write a function that takes an array and a number n as arguments and return

Write a function that has int parameter n, makes another type of mask having n bit 1's from the left most bit and 32- n bit 0's next. The mask is called netmask in this seminar, an