may need some corrections....

there would be many solutions to this
assuming that a[i,j]=0 implies that i lost to j and a[i,j]=1 implies that i
won from j

every 0 will give rise to a sequence

a is players matrix, b is the result seq
static int player=0;
for (player <N;player++)
{
    findSeq(player, b);
}


void findSeq( int prevPlayer, int []b)
{
    if(curPlayer==N)
       {
           print(b);return;
       }

   for (int curPlayer=0; curPlayer<N;curPlayer++)
   {
       if (curPlayer==player) continue;//to avoid loop case
       if (a[b[prevPlayer-1],curPlayer])
       {
          b[prevPlayer]=curPlayer;
          findSeq(prevPlayer+1,b);
       }
      else continue;

   }
}



Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652


On Sat, Jul 31, 2010 at 3:55 PM, jalaj jaiswal <jalaj.jaiswa...@gmail.com>wrote:

> put all the players in a stack
> now pop two players from stack
> insert the winning player in to a circular doubly linked list.
> now repeat the procedure and while inserting in doubly linked list if the
> linked list is not null then start from tail and compare the popped node
> with it that whether it won, if it won then make it the tail if not then
> move inwards ... i.e insert it before the node it won against.
>
>
> On Sat, Jul 31, 2010 at 3:45 PM, Ram Kumar <harrypotter....@gmail.com>wrote:
>
>> Consider there are N players who have a round robin tournament.
>> input is a data structure which says who won the match for every pair <i ,
>> j> i != j .
>> write an algo to give a sequence A[1...n] such that for ever i , i th
>> player lost to i+1 th player and won against i-1 th player.
>>
>> --
>> Regards,
>> Ramkumar.G
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> IIIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@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.

Reply via email to