← Oracle Interview Insights

Oracle·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Oracle backend engineer interview with a graph/cycle detection problem. Pretty standard algorithmic round, nothing too wild, but it's the kind of question that trips you up if you haven't thought about topological sort recently.

Questions Asked (1)

Q1

Given a list of jobs and their dependencies (each job requires another to finish first), determine whether it's possible to complete all jobs.

Algorithms & Data Structures
Author's notes

Classic cycle detection in a directed graph.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the jobs and dependencies as a directed graph where an edge from A to B means job A must be completed before job B. Then, determine if the graph is a Directed Acyclic Graph (DAG) by attempting a topological sort using Kahn's algorithm (BFS) or DFS cycle detection. If a topological ordering exists, all jobs can be completed; otherwise, a cycle prevents completion.

Pro tip: Clarify edge direction upfront (e.g., 'dependency → dependent') to avoid confusion, and mention that this problem is equivalent to cycle detection in a directed graph. Also, discuss how you would handle large inputs by using iterative BFS instead of recursive DFS to avoid stack overflow.

1. Clarify and Model the Problem

Confirm the input format and define the graph: each job is a node, and a dependency is a directed edge from the prerequisite job to the dependent job. Ask if there can be multiple dependencies or if the graph is connected.

2. Choose an Algorithm

Select either Kahn's algorithm (BFS-based topological sort) or DFS-based cycle detection. Explain that both run in O(V+E) time and O(V+E) space.

3. Implement the Algorithm

For Kahn's: compute in-degrees, enqueue nodes with in-degree 0, process until queue empty, and count processed nodes. For DFS: track visited and recursion stack to detect back edges.

4. Interpret the Result

If all nodes are processed (Kahn's) or no back edge is found (DFS), return true; otherwise, return false. Explain that a cycle indicates a circular dependency, making completion impossible.

5. Analyze Complexity and Edge Cases

State time and space complexity, and discuss edge cases: empty list, single job, self-loop, disconnected components, and duplicate edges.

Key Points to Mention

  • Directed graph representation: adjacency list for efficiency.
  • Topological sorting as the core concept.
  • Kahn's algorithm (BFS) vs. DFS with recursion stack.
  • Cycle detection as the key condition for impossibility.
  • Time and space complexity: O(V+E).
  • Handling edge cases: empty input, self-dependencies, disconnected graphs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.