Question: THESE ARE THE CODES : - I KNOW IT IS LENGTHY BUT IF YOU COULD GIVE ME A DETAILED EXPLANATION ON HOW TO APPROACH AND


THESE ARE THE CODES :-

I KNOW IT IS LENGTHY BUT IF YOU COULD GIVE ME A DETAILED EXPLANATION ON HOW TO APPROACH AND SOLVE THIS PROBLEM PLEASE!!!!
*PYTHON ONLY*
EXERCISE 5 PART A (3 pts.): Write a function called recursiveFind that takes a list of integers as input and "walks down the list" recursively, from the first element of the list to the last element of the list, searching for the integer value assigned to a variable called find target (find target is a global variable that is assigned a value outside recursiveFind but that is also used inside recursiveFind for comparison tests; see below HINTS). Your program must print out to the command console the number of times that find_target is discovered in the list, like this: Total occurrences of find target in list: 2. Furthermore, your program MUST NOT ALTER the original input list! Remember: Lists are MUTABLE! Thus, altering the original input list inside recursiveFind (for example, by "popping" it; see below HINTS) may get you into trouble becauses the altered list will then be passed into each subsequent, recursive call to the function recursiveFind Your program must be able to handle input lists of arbitrary length, including the empty list. HINTS: Upon entry into recursiveFind function, the function must first check to see if the incoming list is empty. To do that, and assuming that the incoming list is assigned to a variable called Ist, use the following IF statement test: if not lst: That test will return True when Ist is equal to the empty list (i.e., when it equals []) If an empty list was input to recursiveFind, then your function recursiveFind should return the value 0 immediately Next, and assuming that the input list is not empty, you should POP THE FIRST ELEMENT OF THE LIST (assuming that your list is assigned a variable called Ist, we pop the first element of Ist by issuing the following comm and: Ist.pop(o)). Popping the first element a list does two things: (1) It produces a value that you can compare immediately using an IF statement; and (2) The list is reduced in size by one element. If by popping the list you detect that the value popped is NOT EQUAL TO find target, then recursiveFind should return the value 0 the value returned by another call to recursiveFind. Otherwise, if you detect that the value popped is in fact EQUAL TO find_target, then recursiveFind should return the value of 1 + the value returned by another call to recursiveFind
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
