I was going through the explanation for **Rod Cutting Problem** on geeksforgeeks and there this code was mention to solve Rod Cutting Problem but i am weak in recursion and don’t know anything about DP.

And i am unable to visualize what is happening there in this code in **recursive part**.

So Please can anyone help me out please…!!

**Problem Statement:**

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.

**And here is the code:**

```
// A Naive recursive solution for Rod cutting problem
#include<stdio.h>
#include<limits.h>
// A utility function to get the maximum of two integers
int max(int a, int b) { return (a > b)? a : b;}
/* Returns the best obtainable price for a rod of length n and
price[] as prices of different pieces */
int cutRod(int price[], int n)
{
if (n <= 0)
return 0;
int max_val = INT_MIN;
// Recursively cut the rod in different pieces and compare different
// configurations
for (int i = 0; i<n; i++)
max_val = max(max_val, price* + cutRod(price, n-i-1));
return max_val;
}
/* Driver program to test above functions */
int main()
{
int arr[] = {1, 5, 8, 9, 10, 17, 17, 20};
int size = sizeof(arr)/sizeof(arr[0]);
printf("Maximum Obtainable Value is %d
```

", cutRod(arr, size));

getchar();

return 0;

}

**Resource Link:** http://www.geeksforgeeks.org/dynamic-programming-set-13-cutting-a-rod/

Help Please…!!

Thank you…