Question: What is the optimal substructure in this problem? 2 . A cake company, CScake, is selling a particular type of cakes. Every morning, at the

What is the optimal substructure in this problem? 2. A cake company, CScake, is selling a particular type of cakes. Every morning, at the retail store S, the staff would receive a big cake of size n. The store can sell slice of the cake of size i for any 1<= i <= n, and the list of selling prices of slices of each size is attached. (Both i, n are positive integers.) The staff needs to find out a way to split the big cake into slices in a way that maximizes their revenue. Each slice has to be of integer size. We assume all slices will be sold by the end of the day. Consider the following algorithm to solve this problem which outputs the maximum revenue, and answer the following questions. int splitCake(int priceList [], int n){ if (n=0){ return 0 ; 3 int max Value = INT_MIN; for ( int i=1 ; i<=n ; i++){ int revenue = priceList [i]+ splitCake(priceList, n-i); if ( revenue > maxValue){ max V alue = revenue; }} return maxValue; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!