Sequential examination is not the only way to find the maximum element on a list. Another way to do this is to have the elements play in a tournament much like is done in athletic events. This is accomplished by comparing each pair of elements on the list and moving the largest on to the next round.
Here is the algorithm to do this:
for i=1 to n do p[i]:=a[i]
k=n (the match list size)
while k>1 do
for i=1 to k do
if p[2i]>p[2i-1] then p[i]=p[2i]
This algorithm works for an even amount of players. I'm trying to make it work for odd number of players and basically make it work for any quantity of players.
What i thought as a solution was to add a random function if the amount of teams is odd. The team selected from the list with this rand will have a bye in the first round. Does this make sense? If it does, where do i put it in algorithm? Any suggestions?