Question: A strictly increasing consecutive subsequence is a part of a sequence in which every element is strictly greater than the previous element. Because strictly increasing
A strictly increasing consecutive subsequence is a part of a sequence in which every element is strictly greater than the previous element. Because strictly increasing consecutive subsequence is a bit long, we will call this a streak. For example, in the sequence the subsequences and are streaks. Of course, by definition, any subsequence of a streak is also a streak. is the longest streak among all streaks of that input sequence.
Below is a function that takes as argument a sequence of numbers, and it aims to return the length of the longest streak of the input sequence:
def longeststreakseq:
i
counter
narray
#base case
if lenseq:
return
while i lenseq:
if seqi seqi:
countercounter
ii
else:
narray.appendcounter
counter
ii
if lennarray:
returncounter
else:
returnmaxnarray
However, the function above is not correct.
a Provide an example of argument, of correct types, that makes this function return the wrong answer or that causes a runtime error. The argument must be a sequence of numbers.
b Explain the cause of the error that you have found, ie what is wrong with this function. Your answer must explain what is wrong with the function as given. Writing a new function is not an acceptable answer, regardless of whether it is correct or not.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
