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

#questio A charitable organization wants to design a special ATM machine to be used by needy people. The association supplies the needy person with a pin number to be able to use

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 task is to convert S to palindrome

Question 1: (a) Describe the following objects and condition states: (i) ifstream and ofstream objects (ii) eof(), fail(), bad() and good() functions. (b) Write a C++ pr

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

A: Multiple providers of libraries might employ common global identifiers causing a name collision whereas an application attempt to link with two or more such libraries. The names

Program is to perform string operations: Program is to perform string operation without using in built functions using classes and object void mainmenu()    {    clrs


All languages are divided into six sections: - variables, I/O maths, conditional expressions, arrays, functions, subroutines and file handlers. Learning a software language is simi

check this link: http://cactus.eas.asu.edu/partha/Teaching/430.2013/Project/proj-2.2013.htm