i need help with recursive ps3 http://dpaste.com/587343/ this is iterative thanks
Do you have any code for the recursive version(even if it doesnt work)?
Hi Jhonny, looking at your iterative code, I think you will make your life easier if you look into the find() method that they talk about in the readings. This might also make it easier to make the jump from iterative to recursive Instead of having to do the nested for loops, you can use a while and say index = find(target, key, index[starting point in the string]) and this will give you the index of the first occurrence of the key in the target. Then it should run again starting from index+1 (after the previous found).The while should run this until the index returns -1 which is what find() spits out when it can't find the key. If you're counting each of these, you should return the total amount of occurrences. The trick to changing it into a recursive formula is knowing that find() will return the FIRST occurrence and thinking about what you can pass to another instance of the method to be able to scan the whole string.
Join our real-time social learning platform and learn together with your friends!