Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a recursive method that counts the number of nonoverlapping occurrences

ID: 3638161 • Letter: 1

Question

1. Write a recursive method that counts the number of nonoverlapping occurrences of a substring in a given string
2. You have been offered a one month job that pays as follows: On the first day of the month, you are paid 1 cent.On the second day, 2 cents, on the third, 4 cents, and so forth; the amount doubles every day. Write a recursive method that, given the day number, computes the amount of money paid that day. Would you want this job?

Explanation / Answer

count=0 def countSubStringMatchRecursive(target,key): index=find(target,key) global count targetstring=target if index>=0: count=count+1 target=target[index+len(key):] countSubStringMatchRecursive(target,key) else : pass return "No. of instances of", key, 'in', targetstring, 'is', count