Re: [algogeeks] A SIMPLE QUESTION

2011-05-07 Thread Wladimir Tavares
A box can be distributed to more than one student. I can't use two boxes of candy to distributed to a student. Wladimir Araujo Tavares *Federal University of CearĂ¡ * On Thu, May 5, 2011 at 11:27 AM, karthik loganathan karthik.algog...@gmail.com wrote: sorry K should be equal to N On

Re: [algogeeks] A SIMPLE QUESTION

2011-05-07 Thread Wladimir Tavares
The number of candies that each student receives varies between [0, m] start = 0 end = m Do a binary search to find the largest possible value that can be distributed. sol = 1; while (start end) { middle = (start + end) / 2; ensure that all students can receive the same number of sweets middle

Re: [algogeeks] A SIMPLE QUESTION

2011-05-05 Thread karthik loganathan
for the given criteria,surely K should be equal to one,so distribute the candies in each box to each student... On Mon, May 2, 2011 at 9:06 AM, tillegomezz tille...@gmail.com wrote: I have n boxes each with m candys, I want distributed these candys among k students what is the best way for

Re: [algogeeks] A SIMPLE QUESTION

2011-05-05 Thread karthik loganathan
sorry K should be equal to N On Thu, May 5, 2011 at 7:56 PM, karthik loganathan karthik.algog...@gmail.com wrote: for the given criteria,surely K should be equal to one,so distribute the candies in each box to each student... On Mon, May 2, 2011 at 9:06 AM, tillegomezz tille...@gmail.com

[algogeeks] A SIMPLE QUESTION

2011-05-01 Thread tillegomezz
I have n boxes each with m candys, I want distributed these candys among k students what is the best way for distribute them such that 1. All students get equal number of candies. 2. All the candies which a student get must be from a single box only. -- You received this message because you

[algogeeks] Re: Simple Question about simple algorithm

2006-06-12 Thread Pankaj Dekate
Hi , here goes the code.. let's say you have an array of n numbers.Here n could be 1,2,3.. it goes as follows: function bubblesort (A : list[1..n]) { var int i, j; for i from n downto 1 { for j from 1 to i-1 { if (A[j] A[j+1]) swap(A[j],