Signal Strength: Difference between revisions
imported>Plg5 No edit summary |
imported>Kmk21 No edit summary |
||
Line 26: | Line 26: | ||
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. | 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. | ||
[[Category:ICPC Problems]] | |||
[[Category:midatl2008]] | |||
[[Category:Topological Sort]] | |||
[[Category:Dijkstra]] | |||
[[Category:Algorithm Medium]] | |||
[[Category:Implementation Medium]] |
Latest revision as of 03:23, 2 June 2015
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.