Locally optimal choices building global solutions — scheduling, Huffman codes, and more.
12 visualizations
Selects the maximum number of non-overlapping activities by always taking the one that finishes earliest.
Maximizes value under a weight limit when items can be split, by greedily taking the highest value/weight ratio first.
Schedules unit-time jobs to maximize profit by taking the most profitable jobs first and placing them in the latest free slot before their deadline.
Builds an optimal prefix-free binary code by repeatedly merging the two lowest-frequency nodes into a tree.
Repeatedly takes the largest denomination that does not exceed the remainder.
Assigns intervals to the minimum number of non-overlapping resources.
Minimizes total pairwise merge cost by repeatedly merging the two smallest files.
Repeatedly selects the set covering the most still-uncovered elements.
Finds a start that completes a circular gas route, or proves none exists.
Maintains the farthest reachable index while scanning once.
Schedules repeated tasks with a mandatory cooldown and minimum idle time.
Traces selection, crossover, mutation, and replacement.