#include void firstfit(int p_size[],int n,int m_size[],int m) { printf("\n\n"); printf("\t\tFIRST FIT \n"); int i,j,flag,psize[100],msize[100]; for(i=0;i=psize[i]) { printf("%d allocated in %d block ",psize[i],msize[j]); msize[j] = msize[j]-psize[i]; printf(" : %d remaining Memory\n",msize[j]); flag=1; break; } } if(flag==0) { printf("%d cannot be allocated \n",psize[i]); } } } void worstfit(int p_size[],int n,int m_size[],int m) { printf("\n\n"); printf("\t\tWORST FIT \n"); int i,j,max,loc,psize[100],msize[100]; for(i=0;imax) { max = msize[j]; loc = j; } } if(max>=psize[i]) { printf("%d allocated in %d block ",psize[i],msize[loc]); msize[loc] = msize[loc]-psize[i]; printf(" : %d remaining Memory \n",msize[loc]); } else { printf("%d cannot be allocated \n",psize[i]); } } } void bestfit(int p_size[],int n,int m_size[],int m) { printf("\n\n"); printf("\t\tBEST FIT \n"); int i,j,max,loc,psize[100],msize[100]; for(i=0;i=psize[i]) { if(loc == -1) { loc = j; } else if(msize[loc]>msize[j]) { loc = j; } } } if(loc != -1) { printf("%d allocated in %d block",psize[i],msize[loc]); msize[loc] = msize[loc]-psize[i]; printf(" : %d remaining Memory \n",msize[loc]); } else { printf("%d cannot be allocated \n",psize[i]); } } } void main() { int i,p_size[100],m_size[100],n,m; printf("Enter the number of processes : "); scanf("%d",&n); printf("Enter the processess : "); for(i=0;i