Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 6 Online
OpenStudy (anonymous):

pset3 problem 1 countSubStringMatchRecursive Hello Are there any other approaches for writing recursive function in pset3 problem 1 http://dpaste.com/hold/692393/

OpenStudy (anonymous):

Your solution is identical to mine. Now, I'm not qualified enough to say that there are definitely no other (significantly different #ambiguousqualifyingstatement) ways to do this, but I don't think there are. In any case, I think that this is the most concise recursive solution to the problem. Well done. @Everyone_else: I'd be happy to see other solutions if anyone else has one.

OpenStudy (anonymous):

Hmm, I didn't look closely enough, but you could change one (very minor) thing. This would only change, very insignificantly I think, the run-time of your code and does not affect its accuracy. Technically, you can change your search to start at zz+len(key)+1 instead of zz+1, so you'll skip checking strings you know to be in the key. Not sure if this is even worth mentioning, but hey whatever. Definitely gj though

OpenStudy (maitre_kaio):

That was my approach first, but then I realize it just depends on the way you specify the function. Let's say, for example, that the target is 'aaaa' and that the key is 'aa' - with swdalb version, count = 2 - with den2042 version, count = 3 The two versions are correct, since it's just different interpretations of the same specification. Obviously, it means that the specification is not precise enough and that in the real world we would need to improve it.

OpenStudy (anonymous):

here are two; both variations of a theme http://dpaste.com/693400/

OpenStudy (anonymous):

Thank you all for your responses. @bwCA it's great stuff

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!