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
Can you help me with a C++ project?

conceptual difference between big o,big thete and big omega

Write a function that takes in a number n and divides the screen into n vertical bars, alternating black and white. (What should you do if someone puts in n=0 or n=-99?)

Write three functions in C or C++: one that declares a large array statically, one that declares the same large array on the stack, and one that creates the same large array from t

I want a Reverse engineer a .exe to obtain the code Project Description: I'd like to get the full C++ source code from a .exe please Skills required is C++ Programming

FUNCTIONS It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling functio

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Custom Scans and Alerts Think or Swim Project Description: I am seeking somebody to make me several Custom Scans and Alerts on Thinkorswim TOS Skills required are C++ Prog

example of program to ad two numbers

I hv an assignment to do, I almost done. But i cant find whats wrong- my code is to make a simple calculator using function''s all 4 patterns. I did like this- #include int add