You are in a book shop which sells n different books. You know the price and number of pages of each book.
You have decided that the total price of your purchases will be at most x. What is the maximum number of pages you can buy? You can buy each book at most once.
In: 4 10 4 8 5 3 //price 5 12 8 1 //pages Out: 13 Explaination: You can buy books 1 and 3. Their price is 4+5=9 and the number of pages is 5+8=13
This is my recursive approach :
f(x, 0)=max( f(x-price[indx], indx+1) + pages[indx], f(x,indx+1) );
I am having difficulty making the base case, what should be the base case?