Modeling the Problem

Why Modeling Matters

Modeling is the art of translating your real-world application into a precisely-defined, well-understood problem. It's the bridge between practical problems and algorithmic solutions.

circle-check

Good modeling can eliminate the need to design new algorithms entirely—by recognizing that someone has already solved your problem in a different context.

The Modeling Challenge

Real-world applications involve concrete objects: network traffic, classroom schedules, database patterns. But algorithms work on abstract structures: permutations, graphs, sets.

Your task: Describe your problem abstractly in terms of fundamental structures.

You won't find "widget optimization" in an algorithms textbook. But once you recognize that widget optimization is really about finding the shortest path in a graph, suddenly decades of research becomes available to you.

Fundamental Combinatorial Objects

Common Structures and Their Triggers

Arrangements or orderings of items

Examples: {1,4,3,2} vs {4,3,2,1}

Trigger words: "arrangement," "tour," "ordering," "sequence"

Applications: Robot tour optimization, sorting

Modeling real-world structures
circle-info

Skiena Figure 1.9: Real-world structures mapped to abstract objects. (Left) A family tree as a hierarchical tree structure. (Right) A road network as a graph with cities as vertices and roads as edges.

A Word of Caution

Modeling is constraining—some details won't fit perfectly into the target structure. Some problems can be modeled multiple ways, with vastly different results.

Don't be too quick to declare your problem "unique and special." Temporarily ignore details that don't fit—they might not be fundamental after all.

Recursive Objects

Recursion means seeing big things as being made from smaller things of exactly the same type.

How Each Structure Decomposes

  • Remove the first element from {4,1,5,2,3} → renumber to get {1,4,2,3}

  • A permutation of n things becomes a permutation of n−1 things

Think of a house as a set of rooms: add or delete a room, and you still have a house.

Recursive decompositions
circle-info

Skiena Figure 1.10: How to break down combinatorial objects recursively. (Left column) Permutations, subsets, trees, graphs. (Right column) Point sets, polygons, strings. Each structure can be decomposed into a smaller version of itself.

Recursion Requires Two Parts

  1. Decomposition rules: How to break the object into smaller pieces

  2. Base cases: Where to stop (the smallest meaningful object)

Typical base cases:

  • Permutations/subsets: {} (empty set)

  • Trees/graphs: single vertex

  • Points: single point

  • Polygons: triangle (smallest valid polygon)

  • Strings: "" (empty string)

circle-exclamation

Why This Matters

Recursive decompositions drive many algorithms in this book. Recognizing recursive structure in a problem often leads directly to elegant algorithmic solutions.

Keep your eyes open for recursive patterns—they're everywhere in computer science.

Last updated