CoursesTrees & Graphs

Graph Foundations

Lessons
9
Exercises
57
Minutes
58
  1. 1

    Nodes, Edges, and the Visited Set

    Graphs are just nodes plus edges — learn the adjacency list, the undirected two-way rule, and why cycles make a visited set mandatory.

    Complete codeMultiple choice
    6 exercises
    5 min
  2. 2

    Find Center of Star Graph

    The center touches every edge — so two edges are all the evidence you need. Structure guarantees can turn O(n) into O(1).

    Complete codeMultiple choiceTap
    6 exercises
    5 min
  3. 3

    Find the Town Judge

    Trust pairs are directed edges — the judge is pure degree bookkeeping: in-degree n - 1, out-degree 0, one score array.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  4. 4

    Find if Path Exists in Graph

    Your first real traversal: turn the edge list into an adjacency list (both directions!), then BFS outward from the source with a visited set until the destination appears — or the frontier runs dry.

    Complete codeMultiple choiceTrace
    6 exercises
    6 min
  5. 5

    Keys and Rooms

    Reachability in disguise: rooms are nodes and keys are directed edges. Start in room 0, collect keys as you go, and succeed only if visited ends up covering every room.

    Complete codeDebugMultiple choiceTrace
    6 exercises
    6 min
  6. 6

    All Paths From Source to Target

    From 'can I get there?' to 'every way to get there': DFS carries the current path, records a COPY at the target, and backtracks on the way out. No visited set — it would erase answers.

    Complete codeDebugMultiple choiceTrace
    7 exercises
    7 min
  7. 7

    Graph Foundations CheckpointCheckpoint

    No new concepts — transfer the island's graph moves to unseen problems: counting connected groups from a matrix, zero in-degree reasoning, tree-shaped edge lists, and celebrity-style degree bookkeeping.

    Complete codeCode orderMultiple choiceTrace
    6 exercises
    7 min
  8. 8

    Graph Foundations ReviewReview

    Mixed recap of the island: building undirected adjacency both ways, why cycles demand a visited set, when counting degrees beats walking, reachability versus path enumeration, and where O(V + E) comes from.

    Complete codeMultiple choiceTrace
    6 exercises
    6 min
  9. 9

    Boss: Clone GraphBoss

    The island's final test: deep-copy a connected undirected graph — every node AND every edge rebuilt as new objects. The trap: a visited SET can say 'been here' but cannot hand back the clone you built; an old-to-new HashMap does both jobs at once.

    Complete codeDebugCode orderMultiple choiceTrace
    8 exercises
    10 min
AlgoFox Pro

Trees & Graphs is part of AlgoFox Pro

You can read the whole course outline here. The exercises are in the app, along with your streak, your mistake review, and the progress that carries across your devices.

Pro starts with a 3 day free trial. The app store decides who is eligible for an introductory offer, and a lapsed subscription does not get another one.

Download AlgoFox on the App StoreGet AlgoFox on Google Play

Already subscribed in the app? Sign in with the same account and Pro works here too. Quick Play and Battle are free on the web, and so is the first course in every subject.