Question: What would be the algorithm for the following C code? Can I just get pseudocode, please? // LFU algorithm int * LFUAlgorithm( int n, int
What would be the algorithm for the following C code? Can I just get pseudocode, please?
// LFU algorithm int* LFUAlgorithm(int n, int *in, int nf) { int p[nf]; int hit=0,i,j,k; int pageFault = 0; static int PageFaultcount[] = {0,0,0,0,0}; int usedCount[nf]; int least,repin,sofarcnt=0,bn; pageFault=0; for(i=0; ifor(i=0; ifor(i=0; iif(i%2000 == 0 && i > 0) { PageFaultcount[((i/2000)-1)] = pageFault; // printf(" LFU : %d = %d", i, pageFault); } if(isHit(in[i], nf, p)) { int hitindex=getHitIndex(in[i],nf, p); usedCount[hitindex]++; } else { pageFault++; if(bnelse { least=9999; for(k=0; kif(usedCount[k]for(k=0; k<=i; k++) if(in[i]==in[k]) sofarcnt=sofarcnt+1; usedCount[repin]=sofarcnt; } } } PageFaultcount[4] = pageFault; // printf(" LFU : Total no of page faults:%d",pageFault); return PageFaultcount; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
