Sunday, March 7, 2010

G. Polya, "How to Solve It"....Subsequence part I

So I took some time over the week to think though my previous suggested solution. I couldn't get it to work and it seemed that the idea was wrong so I decided to drop it.
While checking up on the website this week I came across the requirements for this SOLG and came across the the article name in the title. Well, I figured considering my situation this would be a good time to use it, and I think It actually helped.
Here it is...

UNDERSTANDING THE PROBLEM
I drew out various possible test cases for the sub sequence problem and determined at each step what I know about the data, condition and variable.
DEVISING A PLAN
The plan I came up with is very simple.
Search for the first occurrence in the string of the first character in the sub string.
Once found call a recursive function that returns the number of times the next letter in the substring occurs after the current index. This creates a recursive function that returns the number of times that the substring occurs for that first letter. Do this on every time the first letter is seen and the result should be the number of times that substring occurs in the string.
CARRYING OUT THE PLAN

To be continued.....

No comments:

Post a Comment