Lesson 2 of 3Module 1 · 0% of course
Data Structures & Algorithms · Complexity

Choosing a data structure

List, tuple, set, dict, deque: pick the right container and half the algorithm writes itself.

15 min · 4 steps · videoJump to quiz ↓
4. Hashing MIT OpenCourseWare · 53 min
Open in YouTube
Step 1 of 4 · Overview15 min read ·
StructureOrderedMutableFast atUse for
listyesyesindex, appendsequence of fills
tupleyesnohashable record(trade_id, field)
setnoyesmembership, union/intersectionwhich ids exist
dictinsertionyeskey → value lookuptrades by id
dequeyesyesappend/pop both endsrolling window of prices
ours_ids = {t["id"] for t in ours}
theirs_ids = {t["id"] for t in theirs}
missing_at_cpty = ours_ids - theirs_ids
missing_in_ours = theirs_ids - ours_ids
both = ours_ids & theirs_ids
Key idea
Set algebra does half the reconciler: difference = missing trades, intersection = trades to field-compare.
Next: Practice
‹ PrevNext ›