Validate course catalog dependencies
GoogleSoftware Engineer · Technical ScreenLast updated
This question evaluates understanding of graph algorithms and data validation, specifically dependency analysis, cycle detection, and topological ordering.
Design a function to validate an e-learning course catalog. You are given: (
- a set of course IDs, and (
- a list of prerequisite pairs (u, v) meaning course v requires course u. Determine if the catalog is valid: no prerequisite references a non-existent course, and there are no cycles in the dependency graph. If valid, return true and a possible ordering of courses; otherwise return false and report the set of missing course references and at least one cycle you detect. Specify your algorithm, time and space complexity.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.