Skip to content
StackDecode
GraphsExplained

Hamiltonian Path

A path that visits every node exactly once. NP-complete.

Time

O(n!) brute force, O(2ⁿ · n²) DP

Extra space

O(2ⁿ · n)

Use it for

Small instances; routing puzzles.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.