Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Point Constellation

Learn
Play
Prove
Problem context and objectives
Mission briefing

Realm network architect · Routes have costs, dependencies, and unreliable bridges

Choose the next frontier that preserves the route guarantee: The Point Constellation.

One locally tempting edge can invalidate the whole journey.

How you win

  1. 1Recognize when Prim minimum spanning tree matches the clues
  2. 2Keep this true after every move: the visited points form one tree extendable to a minimum spanning tree
  3. 3Reach the result within O(n squared) with dense frontier updates

Rules and pressure

  • Target cost: O(n squared) with dense frontier updates
  • State rule: the visited points form one tree extendable to a minimum spanning tree
Lesson 1 of 3

Live algorithm trace

Prim minimum spanning tree

Complete execution
1 of 6
0,0
seed
2,2
3,10
5,2
7,0

Seed point 0 with zero connection cost.

1best[0] = 0
2repeat n times
3choose unvisited point with smallest best cost
4add its cost to total
5update every unvisited Manhattan edge
6return total
best = [0,inf,inf,inf,inf]total = 0
Truth to preserve / Cost target
Truth to preserve

the visited points form one tree extendable to a minimum spanning tree

Cost target

O(n squared) with dense frontier updates

Prim grows a connected tree by repeatedly taking the cheapest edge from the tree to an unvisited point. Manhattan distance supplies every implicit complete-graph edge weight.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead