Signal Strength
Introduction
This problem asks to find the maximum signal strength in a non-cyclic graph. There are "servers" which have gain, and a "connections" from a server to another, witch also have a gain.
Difficulty
Algorithmic
Mild. The theory is pretty straightforward and doesn't necessitate a fast algorithm.
Implementation
Moderate. Parsing the information and putting them into the relevant data structures is annoying.
Solutions
Solution using recursion
Idea
Create a function that will recursively determine the signal strength at any server. It will find the strength of all the parent servers, and return the strongest one. Implement memoization for speed
How to
Your program needs 3 layers
- Initial setup layer
- Case layer
- Recursive layer
The recursive function should be called initially on the LAST server, and should work its way up to the FIRST server. Thus, base case is when server #0 is hit.