Recompute Order for Dependent Pricing Curves After a Tick
Last updated: November 29, 2026
Quick Overview
Pricing objects such as curves and surfaces depend on other inputs. Given the dependency map and a set of inputs that just changed, return only the affected objects in an order where every object comes after all of its affected inputs, and report a cycle if one exists.
DRW
November 29, 20260
0
0 solved
Pricing objects such as curves and surfaces depend on other inputs. Given the dependency map and a set of inputs that just changed, return only the affected objects in an order where every object comes after all of its affected inputs, and report a cycle if one exists.
DRW trades rates and options where a futures tick ripples through curves, swaps, and volatility surfaces, so a pricing graph is a natural setting for topological sort. The interviewer wants you to restrict work to the affected subgraph rather than sorting everything, and to detect cycles with a useful message.
What the Interviewer Expects
- Builds reverse edges from input to dependents
- Collects the downstream closure of the changed nodes
- Runs Kahn's algorithm only on that closure
- Detects a cycle when not every affected node is emitted
- Explains O(V' + E') cost for the affected part
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Many ticks arrive per millisecond: how would you coalesce updates?
- How would you parallelize recomputation across cores while keeping order?
- Some nodes are expensive: how would you skip recomputing a node whose inputs changed by less than a threshold?
- How would you precompute order so each tick costs no sorting at all?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
deps[node] lists the inputs of node. changed is a set of nodes. Output: changed nodes plus every transitive dependent, ordered so each node follows its affected inputs. Unaffected nodes (say an ...
High-Level Design
Invert the map so we can walk from an input to its dependents. A DFS from the changed nodes collects the affected set. Then compute in-degrees counting only edges inside the affected set (an unaffecte...