You are given pairwise currency ratios such as "a:b = 1:1.5" and "b:c = 1:1.5". Design functions to:
(
-
store direct conversions;
(
-
answer queries like "A:C" by chaining rates;
(
-
support many queries efficiently;
(
-
when the relations form a DAG with a chosen base currency, compute all currency-to-base rates using a topological ordering;
(
-
explain when a simple map suffices versus when a graph traversal or topological sort is required;
(
-
state time and space complexities and how you handle missing paths or contradictions.