An activity tracking app records a user's daily activity as an array of binary values, daily_activity, where 1 represents an 'active' day and 0 represents an 'inactive' day.
Below is the pseudocode designed to find the length of the longest consecutive active streak (the maximum number of consecutive 1s) in the daily_activity array.
daily_activity ← USERINPUT
max_streak ← 0
current_streak ← 0
idx ← 0
WHILE idx < LEN(daily_activity)
IF daily_activity[idx] == 1 THEN
current_streak ← current_streak + 1
ELSE
IF current_streak > max_streak THEN
max_streak ← current_streak
ENDIF
[LINE_Y]
ENDIF
idx ← idx + 1
ENDWHILE
IF current_streak > max_streak THEN
max_streak ← current_streak
ENDIF
OUTPUT max_streak
Select one option to show what code should be written at point [LINE_Y].
current_streak←1current\_streak \leftarrow 1current_streak←1
max_streak←0max\_streak \leftarrow 0max_streak←0
current_streak←0current\_streak \leftarrow 0current_streak←0
idx←idx+1idx \leftarrow idx + 1idx←idx+1
208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.