Interview concept

What is topological sort?

Topological sort produces a linear ordering of a directed acyclic graph so that every directed edge goes from earlier to later in the order. It resolves dependencies such as build steps, course prerequisites, and task scheduling.

Summary

Key takeaways

Topological sort - Interview Concepts - ExtraBrain is part of ExtraBrain's local-first Mac workflow for live interviews, meetings, transcription, provider control, and responsible AI use.

Page focus

Topological sort produces a linear ordering of a directed acyclic graph so that every directed edge goes from earlier to later in the order. It resolves dependencies such as build steps, course prerequisites, and task scheduling.

Platform fact

ExtraBrain has 1 current public platform family, macOS, with support for 2 Mac CPU families: Apple Silicon and Intel.

Data-flow fact

ExtraBrain has 3 configurable data paths to review before sensitive work: local Parakeet transcription, local Gemma 4 where installed and compatible, and external providers you choose.

Interview concept

How it works

Kahn algorithm

Repeatedly remove nodes with no remaining incoming edges, using in-degree counts and a queue.

DFS approach

Run depth-first search and push each node onto a stack after visiting its descendants, then reverse the stack.

Cycle detection

If no valid ordering exists, the graph has a cycle, so topological sort also detects cycles.

Interview concept

Responsible use

Use any live AI assistant only where interview, workplace, school, and platform rules allow it. Do not use generated answers to misrepresent your skills, experience, or authorship.

FAQ

Common questions.

Short answers for people and crawlers comparing ExtraBrain with other live AI assistants.

When is topological sort possible?

Only on a directed acyclic graph; if the graph has a cycle, no valid ordering exists.

What problems use topological sort?

Build systems, course scheduling, task ordering, and general dependency resolution.