[algogeeks] N number apples needs to distribute across M num baskets of varying capacity in balanced way

2009-09-09 Thread Sandeep .A.S.
Hi, Please let me know is there any standard algorithm to solve the below mentioned problem. Problem statement: I am having 10 apples and 4 basket each basket capacity is as mentioned below: Basket1 : capacity can hold maximum of 2 apples Basket2 : capacity can hold maximum of 4 apples

[algogeeks] Re: random number...

2009-09-09 Thread manish bhatia
Dave, You are correct about the first approach. It is biased towards '1' and of course 000 goes waste. With the second approach, I couldn't find a uniform distribution, because there is no power of 5 which is a multiple of 7, as they are relatively prime. For the errornous approach where 1

[algogeeks] probabiltiy + DP

2009-09-09 Thread Nagendra Kumar
@all: There are k baised coins with probabilty of coming head is P(i) i = 1 to k. If all these coins are tossed together. find the probabilty of getting i heads ( i = k). think in Dynamic Programming. -Nagendra --~--~-~--~~~---~--~~ You received

[algogeeks] Re: N number apples needs to distribute across M num baskets of varying capacity in balanced way

2009-09-09 Thread Bharath Kumar
What does optimal balance mean? In your example case, if you have 10 apples, put 2 in basket1, 4 in basket2, 4 in basket3 and basket4 gets nothing. If you have to make sure that, each basket gets at least one apple, then start distributing apples one by one to each basket until it reaches its

[algogeeks] Re: [Let's Talk] Re: random number...

2009-09-09 Thread ankur aggarwal
http://stackoverflow.com/questions/137783/given-a-function-which-produces-a-random-integer-in-the-range-1-to-5-write-a-fun and wat about it return (((rand_5()+rand_5()+rand_5()+rand_5()+rand_5()+rand_5()+rand_5())-7)%7 + 1 ) --~--~-~--~~~---~--~~ You

[algogeeks] Re: N number apples needs to distribute across M num baskets of varying capacity in balanced way

2009-09-09 Thread Sandeep .A.S.
Hello Bharath, Thanks for your suggestion. I want to distribute the apple across all the basket balanced way. In other words “I want to calculate the optimal number of apples on each basket such a way that free and used space on each basket equal to total percentage of free and used space on