18/29
Part 4 of 6 · Sorting and the latest entryLearn and do

The latest entry at or before a time

A read at a past moment has to find the right version in a history of writes. Level 4's restore asks the same question of its backups.

Walk back from the newest entry

Say rates were published at times 0, 10 and 20, and kept oldest first: [(0, 1.10), (10, 1.12), (20, 1.08)]. To read the rate at time t, walk the list from the newest entry back, and return the first rate published at or before t. If every entry is later than t, no rate existed yet, so return None.

Predict

Rates were published at 0, 10 and 20. The loop walks backward and returns the first one at or before t. What does it give at 15, 25 and -5?

Pick an answer above to see the rest