Resuming without losing the processed prefix

A transit analyst summarizes delays of at least five minutes. The input delays is a finite list of nonnegative integer delays measured in minutes; it may be empty.


Python
def summarize(delays, i, total, count):
    if i == len(delays):
        return (total, count)
    if delays[i] >= 5:
        return summarize(delays, i + 1,
                         total + delays[i], count + 1)
    return summarize(delays, i + 1, total, count)


The standard initial call is summarize(delays, 0, 0, 0). For a resumed call, let k be an integer from zero through the list length, inclusive. Which statements are true? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Context-Preserving Accumulators Questions: