A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
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.
anonymous
 5 years ago
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.

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Think 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
 5 years ago
Best ResponseYou've already chosen the best response.0I 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.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.