[algogeeks] Re: shop keeper and the buyer

2011-08-14 Thread ritu
solution is as following if problem is buy all the n items for
minimum price if there are offers so that item j is free if customer
buys K numbers of item i

1. create two parallel arrays cost[] (cost[i] = item[i] * K ) and
free[](free[i] = j )
2. sort cost[]
3. now for highest priced item ,check if it freely avilable with any
lower cost item
4. add this lower priced item with quantity K to the set
5. else add single quantity of higher priced item to set.
6. remove these item from array and similarly repeat for other items

On Aug 11, 6:19 pm, cegprakash cegprak...@gmail.com wrote:
 there are n number of items available in the shop
 price[] {size n} gives the cost of each item
 and there are quantity[] {size n} means that there are quantity[i]
 number of i'th item

 the shop keeper provides some free items
 if you buy k nos of item i, you will get 1 item j for free (i may be
 equal to j)

 also there can be such offers for many items

 what you have to do is to buy all the items in shop with minimum
 expenditure.
 .

 source: own problem (i don't have the solution)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: shop keeper and the buyer

2011-08-14 Thread Prakash D
@rashmi: there is no confusion for the third item.. so simply u buy all the
third item without any offer

On Mon, Aug 15, 2011 at 12:52 AM, ritu ritugarg.c...@gmail.com wrote:

 solution is as following if problem is buy all the n items for
 minimum price if there are offers so that item j is free if customer
 buys K numbers of item i

 1. create two parallel arrays cost[] (cost[i] = item[i] * K ) and
 free[](free[i] = j )
 2. sort cost[]
 3. now for highest priced item ,check if it freely avilable with any
 lower cost item
 4. add this lower priced item with quantity K to the set
 5. else add single quantity of higher priced item to set.
 6. remove these item from array and similarly repeat for other items

 On Aug 11, 6:19 pm, cegprakash cegprak...@gmail.com wrote:
  there are n number of items available in the shop
  price[] {size n} gives the cost of each item
  and there are quantity[] {size n} means that there are quantity[i]
  number of i'th item
 
  the shop keeper provides some free items
  if you buy k nos of item i, you will get 1 item j for free (i may be
  equal to j)
 
  also there can be such offers for many items
 
  what you have to do is to buy all the items in shop with minimum
  expenditure.
  .
 
  source: own problem (i don't have the solution)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.