• anonymous
problem set 3a, I can't come up with a way to finish off my recursive part of my function. So far I have: def countSubStringMatchRecursive(target,key): if (find(target,key) < 0): return 0; return 1 + countSubStringMatchRecursive(target[find(target, key)],key); i feel like i should replace the 1 in the return statement with the function.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • chestercat
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
Think about what your trying to do. You found the key in the target. Now what you want to do is to renew the search, in the substring(which is the string starting from where you find the key until the end of the target string) also keep in mind that you need to keep track of every instance you find the key string. If you have problems with that, or again with the code. post again and we'll help you.
  • carlsmith
I always find it easier to draw the recursion if I'm struggling with visualising the process. A quick block diagram, with each nested block indented, like regular Python blocks, works for most stuff in practice. [ start ] [ next ] [ next ] Just scribble it on paper and have a look at it. You'll find you've got it sussed before you've drawn very much of it. Don't try and go on like Michaelangelo.

Looking for something else?

Not the answer you are looking for? Search for more explanations.