diff --git a/Dynamic Programming/Cut Rod.cpp b/Dynamic Programming/Cut Rod.cpp new file mode 100644 index 000000000..90e12a532 --- /dev/null +++ b/Dynamic Programming/Cut Rod.cpp @@ -0,0 +1,29 @@ +/*Given a rod of length n inches and an array of prices that +contains prices of all pieces of size smaller than n. Determine +the maximum value obtainable by cutting up the rod and selling +the pieces.*/ + +#include +using namespace std; +int cutrod(int p[],int n) +{ + int r[n+1]; + r[0]=0; + for(int j=0;j