Let us assume that the input data-structure is a matrix G[1..N;1..N]
of dimesion N*N matrix  where G(i,j) = 1 if i !=j and i has won, 0
otherwise.

Note that the required sequence cannot contain 1 as 0th player does
not exists

Following algorithm may be used.

For i:=2 to N, do:
{
  if ( ( G(i , i+1) = 0 ) AND (G( i , i-1) = 1) )
          ouput i ;

}//End of for-loop.

Order of running time O(N).

-- 
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