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
Problem : Change to palindrome A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your ta

array itself is a pinter.explain

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

Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

C Program for FUNCTION OF MERGE #include conio.h> #include stdio.h> char cot(char a[],char b[]); void main() {           char a[50],b[50];           clrscr()

The program will ask the user to enter: '1' to List the cities(and their state abbrev)  from largest to smallest (by their population) with their population '2'  to List the

Explain the  bit fields portable or not? - No, Bit fields aren't portable. - As Bit fields can't span machine words and number of bits in a machine word is different on diff

draw the flow chart to print the fibonacci series upto n th terms

Project Description: Project Description: I am seeking a programmer who will be able to design some software that will allow the user to: 1) Repeatedly monitor Nike twitter a

I am seeking an expert to create a 360 degree virtual tour in KRPano for use on PCs, tablets and smartphones. You will be given with panoramas in order to create an advanced KRPano