pset3 problem 1
Are there any other approaches for writing recursive function in pset3 problem 1
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.
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
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.