CPKit
v1.6.1

Rod Cutting Solver

AlgorithmsMedium

Cut rods into optimal segments to maximize sales values.

Alt+Shift+R

Configuration Panel

Rod Cutting DP Array Nodes (cuts highlighted)

Time Complexity

O(N^2)

Space Complexity

O(N) tables storage size
Conceptual Overview

The Rod Cutting problem finds the maximum profit obtainable by cutting a rod of length N into smaller pieces and selling them according to a prices list.

Recurrence Relation
dp[i] = max(price[j] + dp[i - j - 1])   for all j in [0, i-1]
State Transitions

Compares the profits of all possible first cuts: making a cut of length j + 1 (yields price[j]) plus solving the remaining subproblem of length i - j - 1.

Source: CP-Algorithms dynamic programming reference