int kod(int *cnts, int i, int *j, int *k, int nsyms) { int r; if(*k > nsyms || i > *j && cnts[*j] < cnts[*k]) { r = cnts[*j]; cnts[(*j)++] = i; } else r = cnts[(*k)++]; return r; }
int huff(int *cnts, int nsyms) { int i = 0, j = 0, k = 0; for(i=0;i<nsyms-1;i++) cnts[i] = kod(cnts, i, &j, &k, nsyms) + kod(cnts, i, &j, &k, nsyms); cnts[i] = 2; j = i-1; k = j; while(k) { while(j > 0 && cnts[j-1] >= k) j--; cnts[i--] -= k - j; cnts[i] = (k - j)*2; k = j; } return nsyms - i; }
Name:
Anonymous2017-07-18 13:57
>>68 >big programs 1./prog/riders didn't write anything big(20K+ line of code) 2.Big programs are usually split into small modules. 3.The only case where this could be useful is some huge file like sqlite source amalgamation(which is never edited manually).