________________________________
From: ankur aggarwal <ankur.mast....@gmail.com>
To: algogeeks@googlegroups.com
Sent: Tuesday, 8 September, 2009 9:02:45 PM
Subject: [algogeeks] Re: n balls having k colors
int num_balls[K] = {0}; // one entry per color.
Use num_balls[] to count balls for each color. Now we just need to permute
num_balls[].
"sort balls[] on the basis of code[color_tag]"
wat r u doing here ??
Well for what its worth, here I am sorting balls[] array such that instead of
comparing balls[i] < balls[j], I am comparing, code[color(balls[i])] <
code[color(balls[j])].
On Tue, Sep 8, 2009 at 8:35 PM, manish bhatia <mb_mani...@yahoo.com> wrote:
Assign 0 to K numbers to all K colors, such that color -> color_tag (a number
b/w [0,K-1]).
>code[k] = {0,2,..,k-1}
>foreach (permutation from all possible-permuations of code[])
> sort balls[] on the basis of code[color_tag]
> print balls[]
>
>
>
________________________________
From: ankur aggarwal <ankur.mast....@gmail.com>
>To: lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
>Sent: Sunday, 6 September, 2009 1:36:01 PM
>Subject: [algogeeks] n balls having k colors
>
>
>You have N balls having one of K colors. Arrange them into groups of same
>colors. e.g.
>
>RRRRRRGRG
>can be arranged as
>RRRRRRRGG (Answer)
>GGRRRRRRR
>
>
________________________________
See the Web's breaking stories, chosen by people like you. Check out Yahoo!
Buzz.
>
>
>
@manish
wat is the complexity ??
think about it...
Yeah complexity is way off! Perhaps we can do the following (provided we can
use extra space).
See the Web's breaking stories, chosen by people like you. Check out
Yahoo! Buzz. http://in.buzz.yahoo.com/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---