Skip to content

added solution for Rod Cutting Problem#7

Open
reshmascode wants to merge 1 commit intotarinivenkataraman:mainfrom
reshmascode:main
Open

added solution for Rod Cutting Problem#7
reshmascode wants to merge 1 commit intotarinivenkataraman:mainfrom
reshmascode:main

Conversation

@reshmascode
Copy link

We are given an array price[], where the rod of length i has a value price[i-1]. The idea is simple – one by one, partition the given rod of length n into two parts: i and n-i. Recur for the rod of length n-i but don’t divide the rod of length i any further. Finally, take the maximum of all values. This yields the following recursive relation:

rodcut(n) = max { price[i – 1] + rodCut(n – i) } where 1 <= i <= n

We are given an array price[], where the rod of length i has a value price[i-1]. The idea is simple – one by one, partition the given rod of length n into two parts: i and n-i. Recur for the rod of length n-i but don’t divide the rod of length i any further. Finally, take the maximum of all values. 
This yields the following recursive relation:

rodcut(n) = max { price[i – 1] + rodCut(n – i) } where 1 <= i <= n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant