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

I am doing PS3 problem 1. I have written the code and it works fine. But the assignment says that the definitions should take 2 arguments (target and key). with the recursive code I had to include 2 extra arguments. Has anyone else done the same? Here's my code: Recursive Method: http://codepad.org/RXEaELgE Iterative Method: http://codepad.org/LZgvMDqm

OpenStudy (anonymous):

I post my version of the answer a few days ago. You might want search it. In the meantime I'll have a look at yours

OpenStudy (anonymous):

With the recursive function try the following: When you find an occurence of the searched for string (called substring) within a string you know the start position. When calling the function recursively do not send the entire string but just that part of the string ***one more*** than the position of the previous occurance. Hope this helps.

OpenStudy (anonymous):

ok I'll have a look for your one. Thanks

OpenStudy (anonymous):

http://pastebin.com/ZxVD0jZB

OpenStudy (anonymous):

Very elegant solution bwCA!!

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!