Part B: Recursion 1· [2 marks] Consider the following recursive function. There
ID: 3714034 • Letter: P
Question
Part B: Recursion 1· [2 marks] Consider the following recursive function. There are no syntax errors def mystery (aList): if len (aList)-= 0: If aList[0] % 5 == 0: else: return O return 10 + mystery (aList[1:]) return 1 + mystery (aList[1:]) What is returned by the call mystery([10, 7, 3, 0, 151)? 2. [3 marks] Consider the following recursive function. There are no syntax errors def mystery (aList): if len (aList) 0 : return None == 1: return aList[0] if len (aList) mid = len (aList) //2 right = mystery (aList[mid:)) left - mystery (aList[0:mid]) if rightExplanation / Answer
1.
This recursive function assigns 1 to each element. It assigns 10 if that element is divisible by 5.. It returns total value.
So, weight of 10 is 10
Weight of 7 = 1
W(3) = 1
W(0) = 10
W(15) = 10
So, total is 32
2.
This function recursively calculats minimum value in the given list
mystery([10,7,2,4,3]) = 2
mystery([0]) = 0
mystery([]) = None