Monday, 29 August 2016

Tournament Problem Solution

Solving Tournament Problems using Queue



queue<int > q;

for(int i=1;i<=pow(2,n);i++){
        q.push(i);
    }

while(1){
        i=q.front();
        q.pop();
        if(q.empty()) break;
        j=q.front();
        q.pop();   
        q.push(winner(i,j));   
    }

print i;

No comments:

Post a Comment