Find the Single Points of Failure
Advanced · Write the code · from Fault Tolerance and Redundancy: How the Internet Survives Failures
From the lesson: Where does the real Internet use redundancy?
The same idea shows up at every size: - Between continents, hundreds of cables run along the ocean floor. When a ship's anchor cuts one, traffic shifts to the others. Pages may load more slowly in the affected region, but they still load.
Read this part of the lessonWrite single_points_of_failure(network). It returns a sorted list of the devices whose failure would leave the remaining devices unable to all reach each other. When a device fails, it and all of its connections disappear.
The starter code includes the lesson's can_reach, which you may use.
chain = {'A': ['B'], 'B': ['A', 'C'], 'C': ['B']}
single_points_of_failure(chain) -> ['B']If A fails, B and C can still reach each other, so A is not on the list.
What Check runs
Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(single_points_of_failure({"A": ["B"], "B": ["A", "C"], "C": ["B"]})) | ['B'] |
| print(single_points_of_failure({"A": ["B", "C"], "B": ["A", "C"], "C": ["A", "B"]})) | [] |
| print(single_points_of_failure({"A": ["B", "C"], "B": ["A", "C"], "C": ["A", "B", "D"], "D": ["C", "E"], "E": ["D"]})) | ['C', 'D'] |
More Fault Tolerance exercises
- Count the ConnectionsBeginner
- Still Connected?Intermediate