DSAVisualiseData Structures & Algorithms Studio
Graphs & Connectivity Hard

Contact Bubble Reduction (Greedy)

The exercise greedily removes contacts that keep too-large neighbor sets connected; repeated contacts do not create repeated relationships.

Trace input

Bounded JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestO(C + P)
AverageO(C + P)
WorstO(C·P)
SpaceO(P + C)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Follow the source’s two passes and return each forbidden pair in the order it is removed.

  • Counting duplicate contacts as separate people.
  • Replacing the source’s greedy two-pass behavior with a different optimization algorithm.

Algorithm code

Java
Bubbles.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1