Michael Angelo Ravera <(E-Mail Removed)> writes:

> Is there some trick to doing a lot better than this given the

> assumptions? The reason that sorting is undesirable is that I

> need to be able to present ranks for several different scores

> for the same contestant. If someone wants to make a credible

> argument that I can sort, compute ranks and ties and present

> the results more efficiently than just computing each as above,

> I am willing to listen.
You are using nested loops to do ranking, with cost O(n**2).

A competently implemented sort-based rank would cost O(n lg n).

If n is small, your loops are probably just as fast, or at any

rate fast enough that the difference doesn't signify. But as

n grows, you should find that the sort-based solution passes

nested loops in performance.

--

char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]

={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p

=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+

2:{i++;if(i)break;else default:continue;if(0)case 1

utchar(a[i&15]);break;}}}