Lessons 26–30 · About 60 min per lesson

Project: log queries

Combine containers, sorting and prefix sums in a batch query tool.

Lesson breakdown

  1. Lesson 26

    Define the timestamp, name and quantity fields for a log record.

  2. Lesson 27

    Build a name-frequency map and sort the log by time.

  3. Lesson 28

    Implement time-window count and total queries.

  4. Lesson 29

    Write a direct-scan reference and compare every result on small data.

  5. Lesson 30

    Deliver the tool, boundary tests and preprocessing and query complexity.

Worked example

Records are (2,Ana,3), (4,Bo,1) and (4,Ana,4). Query Ana’s frequency and statistics at time 4.

How to solve it

Ana appears twice. Time window [4,4] contains 2 records with a total of 5.

Assignment

Finish all three query types and compare with the reference on a fixture with repeated timestamps and missing names.

Check your result

Check all three example results and verify that missing names and empty time windows return 0.