Learn C Programming

Lesson 2 of 9 · Arrays

Module 9 · Arrays

Traversal Patterns: Sum, Maximum, Count

Free with an accountReading

Zara logs the temperature of the freezer in her uncle's shop. A warm freezer spoils the ice cream, so she writes a function that returns the warmest reading.

Sign in to read

This lesson is free, with an account

An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.

What is inside Traversal Patterns: Sum, Maximum, Count

  1. A best that starts at 0
  2. Traversal: one visit per box
  3. The sum, and the average as a double
  4. The maximum starts from a[0]
  5. Keep the index of the best
  6. Count-if: how many pass
  7. Zara's edges: one value, all equal, all negative
  8. A second pass uses the first pass's answer