Legacy Code: Difference between revisions
Jump to navigation
Jump to search
Created page with "This problem gives us a list of function names and the functions that CALL those functions and asks, given the top-level set of functions we know are called, how many listed f..." |
No edit summary |
||
Line 6: | Line 6: | ||
[[Category: gcpc2015]] | [[Category: gcpc2015]] | ||
[[Category: Algorithm Easy]] | [[Category: Algorithm Easy]] | ||
[[Category: Implementation | [[Category: Implementation Easy]] | ||
[[Category: BFS]] | [[Category: BFS]] | ||
[[Category: Graph]] | [[Category: Graph]] |
Latest revision as of 07:31, 25 September 2018
This problem gives us a list of function names and the functions that CALL those functions and asks, given the top-level set of functions we know are called, how many listed functions are not reached?
This is a typical BFS problem. Simply build an adjacency list as you read the input and then BFS from any function which matches the regex "::Program$". Return the count of unreached functions. Ensure to deal with the case of having zero or multiple "program" functions.