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.
Checking what this lesson needs for you…
What is inside Traversal Patterns: Sum, Maximum, Count
- A best that starts at 0
- Traversal: one visit per box
- The sum, and the average as a double
- The maximum starts from a[0]
- Keep the index of the best
- Count-if: how many pass
- Zara's edges: one value, all equal, all negative
- A second pass uses the first pass's answer