11B Best Fit Program:: Sprno:9223
11B Best Fit Program:: Sprno:9223
printf("P%d\t%d\t", i + 1, processSize[i]);
if (allocation[i] != -1)
printf("Block %d\n", allocation[i] + 1);
else
printf("Not Allocated\n");
}
// Display remaining sizes in blocks
printf("\nRemaining Memory in Blocks:\n");
for (int i = 0; i < blocks; i++) {
printf("Block %d: %d\n", i + 1, blockSize[i]);
}
}
int main() {
int blockSize[MAX_BLOCKS], processSize[MAX_PROCESSES];
int blocks, processes;
printf("Enter number of memory blocks: ");
scanf("%d", &blocks);
printf("Enter the sizes of the %d blocks:\n", blocks);
for (int i = 0; i < blocks; i++) {
scanf("%d", &blockSize[i]);
}
printf("Enter number of processes: ");
scanf("%d", &processes);
printf("Enter the sizes of the %d processes:\n", processes);
for (int i = 0; i < processes; i++) {
scanf("%d", &processSize[i]);
}
bestFit(blockSize, blocks, processSize, processes);
return 0;
}
Sprno:9223
OUTPUT:
Enter number of memory blocks: 5
Enter the sizes of the 5 blocks:
100 500 200 300 600
Enter number of processes: 3
Enter the sizes of the 3 processes:
212 417 112